List of usage examples for android.view ViewGroup addView
@Override public void addView(View child, LayoutParams params)
From source file:com.zhongsou.souyue.ui.gallery.UrlPagerAdapter.java
@Override public Object instantiateItem(ViewGroup collection, int position) { UrlTouchImageView iv = new UrlTouchImageView(mContext); iv.setDownLoadLinstener((DownLoadLinstener) mContext); iv.setBgUrl(mResources.get(position)); // iv.setUrl(replaceUrl(mResources.get(position))); iv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); collection.addView(iv, 0); iv.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a2 s .c om public void onClick(View v) { ((Activity) mContext).finish(); } }); return iv; }
From source file:cn.dreamtobe.touchgallery.BaseGalleryPagerAdapter.java
@Override public Object instantiateItem(ViewGroup collection, int position) { if (mResources == null) { return null; }/* ww w.j av a 2 s .c o m*/ final CacheTouchImageView iv = new CacheTouchImageView(mContext); iv.setInterface(this); iv.setUrl(mResources.get(position)); iv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); collection.addView(iv, 0); return iv; }
From source file:com.cranberrygame.cordova.plugin.ad.admob.AdmobSplit.java
protected void addBannerViewOverlap(String position, String size) { ///*/*from w w w .ja va2 s . c om*/ if (plugin.getWebView() != null) { //ViewGroup parentView = (ViewGroup)plugin.getWebView().getParent();//only for ~cordova4 //ViewGroup parentView = (ViewGroup)plugin.getWebView().getRootView();//only for ~cordova4 //ViewGroup parentView = (ViewGroup)plugin.getWebView().getView();//only for cordova5 ViewGroup parentView = (ViewGroup) getView(plugin.getWebView()); if (parentView != null) { if (position.equals("top-left") || position.equals("top-center") || position.equals("top-right") || position.equals("left") || position.equals("center") || position.equals("right")) { parentView.addView(bannerView, 0); } else { parentView.addView(bannerView); } //parentView.bringToFront(); } } Log.d("AdmobPlugin", "position: " + position); //*/ /* FrameLayout v = new FrameLayout(plugin.getCordova().getActivity()); //http://developer.android.com/reference/android/widget/FrameLayout.LayoutParams.html#FrameLayout.LayoutParams(int, int) //http://rerethink.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%BD%94%EB%93%9C%EC%97%90%EC%84%9C-LayoutParams-%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-Gravity-%EC%A3%BC%EA%B8%B0 //http://rerethink.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%ED%85%8C%EC%9D%B4%EB%B8%94%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83-%EC%BD%94%EB%93%9C%EC%83%81-%EC%84%A4%EC%A0%95 FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); bannerView.setLayoutParams(params); v.addView(bannerView); //v.addView(bannerView, params); if (plugin.getWebView() != null) { //ViewGroup parentView = (ViewGroup)plugin.getWebView().getParent();//only for ~cordova4 //ViewGroup parentView = (ViewGroup)plugin.getWebView().getRootView();//only for ~cordova4 //ViewGroup parentView = (ViewGroup)plugin.getWebView().getView();//only for cordova5 // ViewGroup parentView = (ViewGroup)getView(plugin.getWebView()); ViewGroup parentView = (ViewGroup)getView(plugin.getWebView()).getParent(); if (parentView != null) { if (position.equals("top-left") || position.equals("top-center")|| position.equals("top-right") || position.equals("left") || position.equals("center") || position.equals("right")) { //parentView.addView(bannerView, 0); parentView.addView(v, 0); } else { //parentView.addView(bannerView); parentView.addView(v); } //parentView.bringToFront(); } } Log.d("AdmobPlugin", "position: " + position); */ }
From source file:bottombar.BottomBarBadge.java
private void wrapTabAndBadgeInSameContainer(final BottomBarTab tab) { ViewGroup tabContainer = (ViewGroup) tab.getParent(); tabContainer.removeView(tab);/*w w w . j a va 2s . c o m*/ final BadgeContainer badgeContainer = new BadgeContainer(getContext()); badgeContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); badgeContainer.addView(tab); badgeContainer.addView(this); tabContainer.addView(badgeContainer, tab.getIndexInTabContainer()); badgeContainer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { badgeContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this); adjustPositionAndSize(tab); } }); }
From source file:com.community.yuequ.bottombar.BottomBarBadge.java
private void wrapTabAndBadgeInSameContainer(final BottomBarTab tab) { ViewGroup tabContainer = (ViewGroup) tab.getParent(); tabContainer.removeView(tab);//from w ww .j a v a2s . co m final FrameLayout badgeContainer = new FrameLayout(getContext()); badgeContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); badgeContainer.addView(tab); badgeContainer.addView(this); tabContainer.addView(badgeContainer, tab.getIndexInTabContainer()); badgeContainer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { badgeContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this); adjustPositionAndSize(tab); } }); }
From source file:com.manuelpeinado.numericpageindicator.demo.MyPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { TextView item = new TextView(container.getContext()); item.setText(Integer.toString(position + 1)); item.setTextColor(Color.argb(192, 255, 255, 255)); item.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50); item.setGravity(Gravity.CENTER);/*from www . java2 s .c o m*/ item.setBackgroundColor(COLORS[position % COLORS.length]); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); container.addView(item, layoutParams); return item; }
From source file:com.metinkale.prayerapp.BaseActivity.java
@Override public void setContentView(int res) { super.setContentView(R.layout.activity_base); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);/*from ww w .jav a 2s . co m*/ toolbar.setBackgroundResource(R.color.colorPrimary); toolbar.setNavigationIcon( MaterialDrawableBuilder.with(this).setIcon(MaterialDrawableBuilder.IconValue.VIEW_HEADLINE) .setColor(Color.WHITE).setToActionbarSize().build()); } ViewGroup content = (ViewGroup) findViewById(R.id.basecontent); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); View v = LayoutInflater.from(this).inflate(res, content, false); content.addView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mNav = (ListView) mDrawerLayout.findViewById(R.id.base_nav); ArrayAdapter<String> list = new ArrayAdapter<String>(this, R.layout.drawer_list_item, getResources().getStringArray(R.array.dropdown)) { @NonNull @Override public View getView(int pos, View v, @NonNull ViewGroup p) { v = super.getView(pos, v, p); if (pos == mNavPos) { ((TextView) v).setTypeface(null, Typeface.BOLD); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { ((TextView) v).setCompoundDrawablesWithIntrinsicBounds(0, 0, ICONS[pos], 0); } else { ((TextView) v).setCompoundDrawablesWithIntrinsicBounds(ICONS[pos], 0, 0, 0); } return v; } }; mNav.setAdapter(list); mNav.setOnItemClickListener(new MyClickListener()); final String title = list.getItem(mNavPos); mDrawerLayout.post(new Runnable() { @Override public void run() { if (toolbar != null) { toolbar.setTitle(title); } } }); if (getIntent().getBooleanExtra("anim", false)) { mDrawerLayout.openDrawer(GravityCompat.START); mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerLayout.closeDrawers(); } }); } }
From source file:cn.studyjams.s1.contest.autohello.SettingsActivity.java
/** * Set up the {@link android.app.ActionBar}, if the API is available. *///from ww w . j a va 2 s .c o m private void setupActionBar() { ViewGroup rootView = (ViewGroup) findViewById(R.id.action_bar_root); //id from appcompat if (rootView != null) { View view = getLayoutInflater().inflate(R.layout.settings_toolbar, rootView, false); rootView.addView(view, 0); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Show the Up button in the action bar. actionBar.setDisplayHomeAsUpEnabled(true); } }
From source file:de.grobox.liberario.utils.TransportrUtils.java
static private void addLineBox(Context context, ViewGroup lineLayout, Line line, int index, boolean check_duplicates) { if (check_duplicates) { // loop through all line boxes in the linearLayout for (int i = 0; i < lineLayout.getChildCount(); ++i) { // check if current line box is the same as the one we are about to add if (line.label != null && line.label.equals(((LineView) lineLayout.getChildAt(i)).getLabel())) { // lines are equal, so bail out from here and don't add new line box return; }/* w w w .j a v a 2s . c om*/ } } LineView lineView = new LineView(context); lineView.setLine(line); // set margin, because setting in in xml does not work FlowLayout.LayoutParams llp = new FlowLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); llp.setMargins(0, 5, 10, 5); lineView.setLayoutParams(llp); lineLayout.addView(lineView, index); }
From source file:am.util.viewpager.adapter.RecyclePagerAdapter.java
@NonNull public final Object instantiateItem(@NonNull ViewGroup container, int position) { VH holder;/*from www . j av a 2s. c om*/ int viewType = getItemViewType(position); ArrayList<VH> recycleHolders = holderSparse.get(viewType); if (recycleHolders != null && recycleHolders.size() > 0) { holder = recycleHolders.remove(0); holder.mPosition = POSITION_UNCHANGED; } else { holder = createViewHolder(container, viewType); } bindViewHolder(holder, position); container.addView(holder.itemView, 0); return holder; }