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.silentcircle.common.util.ViewUtil.java

/**
 * Sets state (enabled/disabled) for viewGroup and its children.
 *
 * @param viewGroup ViewGroup for which to set state.
 * @param enabled State to set./* ww  w .  j a v a 2s  .c  om*/
 */
public static void setEnabled(final ViewGroup viewGroup, boolean enabled) {
    viewGroup.setEnabled(enabled);
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View view = viewGroup.getChildAt(i);
        view.setEnabled(enabled);
    }
}

From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java

/**
 * DrawerLayout ???/*from   w ww  . j  av a 2s.c  o m*/
 *
 * @param activity       ?activity
 * @param drawerLayout   DrawerLayout
 * @param color          ??
 * @param statusBarAlpha ???
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color,
        int statusBarAlpha) {
    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);
    }
    // ????
    View statusBarView = createStatusBarView(activity, color);
    //  statusBarView 
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    contentLayout.addView(statusBarView, 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);

    addTranslucentView(activity, statusBarAlpha);
}

From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java

/**
 * DrawerLayout ???(5.0??,?)/*w  ww  .java 2s  . com*/
 *
 * @param activity     ?activity
 * @param drawerLayout DrawerLayout
 * @param color        ??
 */
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // ????
        View statusBarView = createStatusBarView(activity, color);
        //  statusBarView 
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.addView(statusBarView, 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.gosuncn.core.util.view.StatusBarUtils.java

/**
 * ???/*from  ww w  . ja  v a 2  s .c  om*/
 *
 * @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:com.gosuncn.core.util.view.StatusBarUtils.java

/**
 * DrawerLayout ???//from   ww  w.j ava 2s  .  co m
 *
 * @param activity       ?activity
 * @param drawerLayout   DrawerLayout
 * @param color          ??
 * @param statusBarAlpha ???
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color,
        int statusBarAlpha) {
    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);
    }
    // ????
    //  statusBarView 
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) {
        contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
    } else {
        StatusBarView statusBarView = createStatusBarView(activity, color);
        contentLayout.addView(statusBarView, 0);
    }
    // ? LinearLayout ,padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(),
                getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(),
                contentLayout.getPaddingBottom());
    }
    // 
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    contentLayout.setFitsSystemWindows(false);
    contentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);

    addTranslucentView(activity, statusBarAlpha);
}

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

@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content))
                .getChildAt(0);/*  w w w.j  a  v  a 2 s .  c  o m*/
        rootView.setPadding(0, 0, 0, 0);
    }
}

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

/**
 * ??//from   w  w w .j  a  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:com.vuze.android.remote.AndroidUtilsUI.java

public static ArrayList<View> findByClass(ViewGroup root, Class type, ArrayList<View> list) {
    final int childCount = root.getChildCount();

    for (int i = 0; i < childCount; ++i) {
        final View child = root.getChildAt(i);
        if (type.isInstance(child)) {
            list.add(child);/*  ww w.j  a  va  2  s  . com*/
        }

        if (child instanceof ViewGroup) {
            findByClass((ViewGroup) child, type, list);
        }
    }
    return list;
}

From source file:com.transitionseverywhere.TransitionManager.java

private static boolean cancelAllSystemLayoutTransitions(View view) {
    boolean canceled = false;
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        canceled = ViewGroupUtils.cancelLayoutTransition(viewGroup);
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            canceled = cancelAllSystemLayoutTransitions(viewGroup.getChildAt(i)) || canceled;
        }/*from w  ww. j av a 2  s.  c o m*/
    }
    return canceled;
}

From source file:Main.java

public static void setupChangeAnimationOneTime(ViewGroup viewGroup) {
    LayoutTransition layoutTransition = viewGroup.getLayoutTransition();
    if (layoutTransition == null) {
        return;/*from   w  ww  . jav  a2  s .  c om*/
    }
    try {
        Method method = LayoutTransition.class.getMethod("enableTransitionType", new Class[] { int.class });
        Field field = LayoutTransition.class.getField("CHANGING");
        method.invoke(layoutTransition, field.get(null));
    } catch (Exception e) {
        setupChangeAnimationOneTime((View) viewGroup);
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View childAt = viewGroup.getChildAt(i);
            setupChangeAnimationOneTime(childAt);
        }
    }
}