Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:com.gosuncn.core.util.view.StatusBarUtils.java

/**
 *  DrawerLayout ???/* w  w  w  .j  a  va 2 s. 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().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        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:co.carlosjimenez.android.currencyalerts.app.MenuTint.java

private static ViewGroup findToolbar(ViewGroup viewGroup) {
    ViewGroup toolbar = null;/*from   www.  j a  va 2  s .  com*/
    for (int i = 0, len = viewGroup.getChildCount(); i < len; i++) {
        View view = viewGroup.getChildAt(i);
        if (view.getClass() == android.support.v7.widget.Toolbar.class
                || view.getClass().getName().equals("android.widget.Toolbar")) {
            toolbar = (ViewGroup) view;
        } else if (view instanceof ViewGroup) {
            toolbar = findToolbar((ViewGroup) view);
        }
        if (toolbar != null) {
            break;
        }
    }
    return toolbar;
}

From source file:co.carlosjimenez.android.currencyalerts.app.MenuTint.java

private static ImageView findOverflowMenuButton(Activity activity, ViewGroup viewGroup) {
    if (viewGroup == null) {
        return null;
    }/*  w  ww.j a  v  a 2 s .  co  m*/
    ImageView overflow = null;
    for (int i = 0, count = viewGroup.getChildCount(); i < count; i++) {
        View v = viewGroup.getChildAt(i);
        if (v instanceof ImageView && (v.getClass().getSimpleName().equals("OverflowMenuButton")
                || v instanceof ActionMenuView.ActionMenuChildView)) {
            overflow = (ImageView) v;
        } else if (v instanceof ViewGroup) {
            overflow = findOverflowMenuButton(activity, (ViewGroup) v);
        }
        if (overflow != null) {
            break;
        }
    }
    return overflow;
}

From source file:biz.bokhorst.xprivacy.Util.java

public static List<View> getViewsByTag(ViewGroup root, String tag) {
    List<View> views = new ArrayList<View>();
    for (int i = 0; i < root.getChildCount(); i++) {
        View child = root.getChildAt(i);

        if (child instanceof ViewGroup)
            views.addAll(getViewsByTag((ViewGroup) child, tag));

        if (tag.equals(child.getTag()))
            views.add(child);//from  w  w w.j a va2s .  c o  m
    }
    return views;
}

From source file:es.usc.citius.servando.calendula.fragments.MedicineCreateOrEditFragment.java

private static ArrayList<View> getViewsByTag(ViewGroup root, String tag) {
    ArrayList<View> views = new ArrayList<View>();
    final int childCount = root.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = root.getChildAt(i);
        if (child instanceof ViewGroup) {
            views.addAll(getViewsByTag((ViewGroup) child, tag));
        }/*  w  w w  . ja  va 2 s  .  c  o m*/

        final Object tagObj = child.getTag();
        if (tagObj != null && tagObj.equals(tag)) {
            views.add(child);
        }

    }
    return views;
}

From source file:com.fastbootmobile.encore.utils.Utils.java

public static void setChildrenAlpha(ViewGroup root, final float alpha) {
    final int childCount = root.getChildCount();
    for (int i = 0; i < childCount; ++i) {
        root.getChildAt(i).setAlpha(alpha);
    }/*from   w  w  w  .  j ava  2  s  .  co m*/
}

From source file:me.anon.lib.Views.java

/**
 * Gets all views of a parent that match an class (recursive)
 * @param parent The parent view//from  w  w w.  j a  v  a 2  s  . c o m
 * @param instance The class to check
 * @return An array of views
 */
public static <T extends View> List<T> findAllChildrenByClass(ViewGroup parent, Class<T> instance) {
    List<View> views = new ArrayList<View>();
    int childCount = parent.getChildCount();

    for (int childIndex = 0; childIndex < childCount; childIndex++) {
        View child = parent.getChildAt(childIndex);

        if (child != null && child.getClass() == instance) {
            views.add(child);
        }

        if (child instanceof ViewGroup) {
            views.addAll(findAllChildrenByClass((ViewGroup) child, instance));
        }
    }

    return (List<T>) views;
}

From source file:me.anon.lib.Views.java

/**
 * Gets all views of a parent that match an class (recursive)
 * @param parent The parent view/*from   w w w. j  av  a2s  .  c  om*/
 * @param instance The class to check by instance
 * @return An array of views
 */
public static <T extends View> List<T> findAllChildrenByInstance(ViewGroup parent, Class<T> instance) {
    List<View> views = new ArrayList<View>();
    int childCount = parent.getChildCount();

    for (int childIndex = 0; childIndex < childCount; childIndex++) {
        View child = parent.getChildAt(childIndex);

        if (child != null && instance.isAssignableFrom(child.getClass())) {
            views.add(child);
        }

        if (child instanceof ViewGroup) {
            views.addAll(findAllChildrenByInstance((ViewGroup) child, instance));
        }
    }

    return (List<T>) views;
}

From source file:com.dmbstream.android.util.Util.java

private static void findNotificationTextColors(ViewGroup group, String title, String content) {
    for (int i = 0; i < group.getChildCount(); i++) {
        if (group.getChildAt(i) instanceof TextView) {
            TextView textView = (TextView) group.getChildAt(i);
            String text = textView.getText().toString();
            if (title.equals(text)) {
                NOTIFICATION_TEXT_COLORS.setFirst(textView.getTextColors().getDefaultColor());
            } else if (content.equals(text)) {
                NOTIFICATION_TEXT_COLORS.setSecond(textView.getTextColors().getDefaultColor());
            }/*from w ww . j a v a  2  s.co  m*/
        } else if (group.getChildAt(i) instanceof ViewGroup)
            findNotificationTextColors((ViewGroup) group.getChildAt(i), title, content);
    }
}

From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java

private static View findChildUnder(ViewGroup parent, float x, float y) {
    final int childCount = parent.getChildCount();
    for (int i = childCount - 1; i >= 0; i--) {
        final View child = parent.getChildAt(i);
        if (isChildUnder(child, x, y)) {
            return child;
        }//from   w  ww .j av a2 s. c  o m
    }
    return null;
}