List of usage examples for android.view ViewGroup getChildAt
public View getChildAt(int index)
From source file:android.support.transition.ViewOverlayApi14.java
static ViewOverlayApi14 createFrom(View view) { ViewGroup contentView = getContentView(view); if (contentView != null) { final int numChildren = contentView.getChildCount(); for (int i = 0; i < numChildren; ++i) { View child = contentView.getChildAt(i); if (child instanceof OverlayViewGroup) { return ((OverlayViewGroup) child).mViewOverlay; }/*from w w w. java2s . c om*/ } return new ViewGroupOverlayApi14(contentView.getContext(), contentView, view); } return null; }
From source file:com.nttec.everychan.ui.theme.CustomThemeHelper.java
private static void setLollipopMenuOverflowIconColor(final ViewGroup toolbar, final int color) { try {/*from w ww .j a va 2 s . co m*/ //for API 23 (Android 6): at this point method Toolbar.setOverflowIcon(Drawable) has no effect toolbar.getClass().getMethod("getMenu").invoke(toolbar); AppearanceUtils.callWhenLoaded(toolbar, new Runnable() { @Override public void run() { try { final ViewGroup actionMenuView = (ViewGroup) findViewByClassName(toolbar, "android.widget.ActionMenuView"); Runnable setOverflowIcon = new Runnable() { @Override public void run() { try { Class<?> toolbarClass = toolbar.getClass(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Drawable overflowIcon = (Drawable) toolbarClass.getMethod("getOverflowIcon") .invoke(toolbar); setColorFilter(overflowIcon); toolbarClass.getMethod("setOverflowIcon", Drawable.class).invoke(toolbar, overflowIcon); } else { ImageView overflowButton = (ImageView) findViewByClassName(actionMenuView, "android.widget.ActionMenuPresenter$OverflowMenuButton"); if (overflowButton != null) { Drawable overflowIcon = overflowButton.getDrawable(); setColorFilter(overflowIcon); overflowButton.setImageDrawable(overflowIcon); } } } catch (Exception e) { Logger.e(TAG, e); } } private void setColorFilter(Drawable overflowIcon) { overflowIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); } }; if (actionMenuView.getChildCount() == 0) { AppearanceUtils.callWhenLoaded(actionMenuView == null ? toolbar : actionMenuView, setOverflowIcon); } else { setOverflowIcon.run(); } } catch (Exception e) { Logger.e(TAG, e); } } private View findViewByClassName(ViewGroup group, String className) { for (int i = 0, size = group.getChildCount(); i < size; ++i) { View child = group.getChildAt(i); if (child.getClass().getName().equals(className)) { return child; } } return null; } }); } catch (Exception e) { Logger.e(TAG, e); } }
From source file:android.support.transition.ViewOverlay.java
public static ViewOverlay createFrom(View view) { ViewGroup contentView = getContentView(view); if (contentView != null) { final int numChildren = contentView.getChildCount(); for (int i = 0; i < numChildren; ++i) { View child = contentView.getChildAt(i); if (child instanceof OverlayViewGroup) { return ((OverlayViewGroup) child).mViewOverlay; }/* w w w . jav a 2s . c o m*/ } return new ViewGroupOverlay(contentView.getContext(), contentView, view); } return null; }
From source file:com.facebook.appevents.codeless.internal.ViewHierarchy.java
public static List<View> getChildrenOfView(View view) { ArrayList<View> children = new ArrayList<>(); if (view != null && view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { children.add(viewGroup.getChildAt(i)); }/* w ww.j a v a 2s. com*/ } return children; }
From source file:li.barter.utils.Utils.java
/** * Test whether a viewgroup already contains a specific instance of a child view * * @param viewGroup// w w w . j a v a 2 s . c o m * @param view * @return */ public static boolean containsChild(ViewGroup viewGroup, View view) { boolean contains = false; for (int i = 0; i < viewGroup.getChildCount(); i++) { if (viewGroup.getChildAt(i).equals(view)) { contains = true; break; } } return contains; }
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???/*from w ww. j av a 2s .com*/ * * @param activity ?activity * @param drawerLayout DrawerLayout */ public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); }
From source file:com.facebook.litho.utils.IncrementalMountUtils.java
/** * Performs incremental mount on the children views of the given ViewGroup. * @param scrollingViewParent ViewGroup container of views that will be incrementally mounted. * @param force whether the incremental mount should always take place, or only if * {@link ComponentsConfiguration.isIncrementalMountOnOffsetOrTranslationChangeEnabled} returns * false.// w ww .ja v a 2 s.co m */ public static void performIncrementalMount(ViewGroup scrollingViewParent, boolean force) { assertMainThread(); if (!force && ComponentsConfiguration.isIncrementalMountOnOffsetOrTranslationChangeEnabled) { return; } final int viewGroupWidth = scrollingViewParent.getWidth(); final int viewGroupHeight = scrollingViewParent.getHeight(); for (int i = 0; i < scrollingViewParent.getChildCount(); i++) { maybePerformIncrementalMountOnView(viewGroupWidth, viewGroupHeight, scrollingViewParent.getChildAt(i)); } }
From source file:am.widget.tabstrip.TabStripHelper.java
private static ViewPager traversal(View root) { if (root == null) return null; if (root instanceof ViewPager) { return (ViewPager) root; }//from w w w. java 2 s. com if (root instanceof ViewGroup) { final ViewGroup group = (ViewGroup) root; final int count = group.getChildCount(); for (int i = 0; i < count; i++) { final ViewPager target = traversal(group.getChildAt(i)); if (target != null) { return target; } } } return null; }
From source file:dev.drsoran.moloko.util.UIUtils.java
public final static Pair<Integer, Integer> getTaggedViewRange(ViewGroup container, String tag) { int tagStart = -1; int tagEnd = -1; final int cnt = container.getChildCount(); for (int i = 0; i < cnt && (tagStart == -1 || tagEnd == -1); ++i) { if (tagStart == -1 && tag.equals(container.getChildAt(i).getTag())) tagStart = i;/*from w ww.ja v a 2 s. co m*/ else if (tagStart != -1 && !tag.equals(container.getChildAt(i).getTag())) tagEnd = i; } if (tagStart != -1) return Pair.create(tagStart, tagEnd != -1 ? tagEnd : cnt); else return Pair.create(0, 0); }
From source file:com.jaspersoft.android.jaspermobile.test.utils.espresso.JasperMatcher.java
public static Matcher<View> childForPositionOf(final int position, final Matcher<View> parentMatcher) { return new TypeSafeMatcher<View>() { @Override/* w w w .java 2s . c om*/ public void describeTo(Description description) { description.appendText( "with child on position " + position + " of parent " + parentMatcher.toString()); } @Override public boolean matchesSafely(View view) { if (!(view.getParent() instanceof ViewGroup)) { return parentMatcher.matches(view.getParent()); } ViewGroup group = (ViewGroup) view.getParent(); if (parentMatcher.matches(view.getParent())) { int childCount = group.getChildCount(); if (position >= childCount) { throw new RuntimeException("Position '" + position + "' should be lower than child count '" + childCount + "'"); } return group.getChildAt(position).equals(view); } else { return false; } } }; }