List of usage examples for android.view ViewGroup addView
public void addView(View child)
Adds a child view.
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ???/*from ww w. j a v a 2 s . co m*/ * * @param activity ? activity * @param statusBarAlpha ? */ private static void addTranslucentView(Activity activity, int statusBarAlpha) { ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content); if (contentView.getChildCount() > 1) { contentView.getChildAt(1).setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0)); } else { contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha)); } }
From source file:Main.java
private static void unwrapView(ViewGroup wrapper) { final int childCount = wrapper.getChildCount(); View[] childViews = new View[childCount]; ViewGroup parent = (ViewGroup) wrapper.getParent(); if (parent != null) { parent.removeView(wrapper);/*from ww w . j ava2 s. c o m*/ } for (int i = 0; i < childCount; i++) { childViews[i] = wrapper.getChildAt(i); } // If there was just one wrapper reuse the wrapper layout // params to ensure correct type for parent if (childCount == 1) { ViewGroup.LayoutParams wrapperParams = wrapper.getLayoutParams(); if (wrapperParams != null) { childViews[0].setLayoutParams(wrapperParams); } } for (int i = 0; i < childCount; i++) { final View childView = childViews[i]; wrapper.removeView(childView); if (parent != null) { parent.addView(childView); } } }
From source file:dev.drsoran.moloko.fragments.TagCloudFragment.java
private final static void addButtons(List<Button> buttons, ViewGroup container) { final int size = buttons.size(); if (size > 1) { // link the first button with last and vice versa final Button b0 = buttons.get(0); final Button bLast = buttons.get(size - 1); b0.setNextFocusLeftId(bLast.getId()); bLast.setNextFocusRightId(b0.getId()); }//from w w w . ja va 2s .co m for (int i = 0; i < size; i++) { final Button button = buttons.get(i); if (i > 0) button.setNextFocusLeftId(buttons.get(i - 1).getId()); if (i < size - 1) button.setNextFocusRightId(buttons.get(i + 1).getId()); container.addView(button); } }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ??//from ww w. ja v a2 s . co m * * @param activity ?activity * @param color ?? * @param statusBarAlpha ??? */ public static void setColor(Activity activity, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); int count = decorView.getChildCount(); if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) { decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { StatusBarView statusView = createStatusBarView(activity, color, statusBarAlpha); decorView.addView(statusView); } setRootView(activity); } }
From source file:ca.rmen.android.scrumchatter.chart.ChartUtils.java
static void addLegendEntry(Context context, ViewGroup legendView, String name, int color) { TextView memberLegendEntry = new TextView(context); memberLegendEntry.setText(name);//from w w w. j ava2 s. co m memberLegendEntry.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); memberLegendEntry.setPadding(0, 0, context.getResources().getDimensionPixelSize(R.dimen.chart_legend_entry_padding), 0); final Drawable icon; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square); memberLegendEntry.setTextColor(color); } else { icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square).mutate(); DrawableCompat.setTint(icon, color); } memberLegendEntry.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); legendView.addView(memberLegendEntry); }
From source file:com.zhicai.byteera.activity.message.ExpressionPagerAdapter.java
@Override public Object instantiateItem(ViewGroup arg0, int arg1) { arg0.addView(views.get(arg1)); return views.get(arg1); }
From source file:com.woodblockwithoutco.quickcontroldock.ui.view.pager.LandscapePanelsAdapter.java
@Override public Object instantiateItem(ViewGroup container, int pos) { container.addView(mViews.get(pos)); return mViews.get(pos); }
From source file:com.vhall.uilibs.util.emoji.EmojiPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { container.addView(views.get(position)); return views.get(position); }
From source file:com.hsy.directseeding.emoji.EmojiViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { container.addView(mGridViewList.get(position)); return mGridViewList.get(position); }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
public static View inflate(Context context, Node node, ViewGroup parent) { View mainView = getViewForName(context, node.getNodeName()); if (parent != null) parent.addView(mainView); // have to add to parent to enable certain layout attrs applyAttributes(mainView, getAttributesMap(node), parent); if (mainView instanceof ViewGroup && node.hasChildNodes()) { parseChildren(context, node, (ViewGroup) mainView); }//from w w w . jav a 2 s . co m return mainView; }