Java Code Examples for android.support.v4.widget.DrawerLayout#getChildCount()

The following examples show how to use android.support.v4.widget.DrawerLayout#getChildCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BarUtils.java    From Android-utils with Apache License 2.0 6 votes vote down vote up
/**
 * Set the status bar's color for DrawerLayout.
 * <p>DrawLayout must add {@code android:fitsSystemWindows="true"}</p>
 *
 * @param drawer        The DrawLayout.
 * @param fakeStatusBar The fake status bar view.
 * @param color         The status bar's color.
 * @param isTop         True to set DrawerLayout at the top layer, false otherwise.
 */
public static void setStatusBarColor4Drawer(@NonNull final DrawerLayout drawer,
                                            @NonNull final View fakeStatusBar,
                                            @ColorInt final int color,
                                            final boolean isTop) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    Activity activity = getActivityByView(fakeStatusBar);
    if (activity == null) return;
    transparentStatusBar(activity);
    drawer.setFitsSystemWindows(false);
    setStatusBarColor(fakeStatusBar, color);
    for (int i = 0, count = drawer.getChildCount(); i < count; i++) {
        drawer.getChildAt(i).setFitsSystemWindows(false);
    }
    if (isTop) {
        hideStatusBarView(activity);
    } else {
        setStatusBarColor(activity, color, false);
    }
}
 
Example 2
Source File: BaseActivity.java    From timecat with Apache License 2.0 6 votes vote down vote up
/**
 * 为了兼容4.4的抽屉布局->透明状态栏
 */
protected void setDrawerLayoutFitSystemWindow() {
    if (Build.VERSION.SDK_INT == 19) {//19表示4.4
        int statusBarHeight = getStatusBarHeight(this);
        if (contentViewGroup == null) {
            contentViewGroup = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
        }
        if (contentViewGroup instanceof DrawerLayout) {
            DrawerLayout drawerLayout = (DrawerLayout) contentViewGroup;
            drawerLayout.setClipToPadding(true);
            drawerLayout.setFitsSystemWindows(false);
            for (int i = 0; i < drawerLayout.getChildCount(); i++) {
                View child = drawerLayout.getChildAt(i);
                child.setFitsSystemWindows(false);
                child.setPadding(0, statusBarHeight, 0, 0);
            }

        }
    }
}
 
Example 3
Source File: BaseActivity.java    From timecat with Apache License 2.0 6 votes vote down vote up
/**
 * 为了兼容4.4的抽屉布局->透明状态栏
 */
protected void setDrawerLayoutFitSystemWindow() {
    if (Build.VERSION.SDK_INT == 19) {//19表示4.4
        int statusBarHeight = getStatusBarHeight(this);
        if (contentViewGroup == null) {
            contentViewGroup = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
        }
        if (contentViewGroup instanceof DrawerLayout) {
            DrawerLayout drawerLayout = (DrawerLayout) contentViewGroup;
            drawerLayout.setClipToPadding(true);
            drawerLayout.setFitsSystemWindows(false);
            for (int i = 0; i < drawerLayout.getChildCount(); i++) {
                View child = drawerLayout.getChildAt(i);
                child.setFitsSystemWindows(false);
                child.setPadding(0, statusBarHeight, 0, 0);
            }

        }
    }
}
 
Example 4
Source File: BarUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * Set the status bar's color for DrawerLayout.
 * <p>DrawLayout must add {@code android:fitsSystemWindows="true"}</p>
 *
 * @param drawer        The DrawLayout.
 * @param fakeStatusBar The fake status bar view.
 * @param color         The status bar's color.
 * @param isTop         True to set DrawerLayout at the top layer, false otherwise.
 */
public static void setStatusBarColor4Drawer(@NonNull final DrawerLayout drawer,
                                            @NonNull final View fakeStatusBar,
                                            @ColorInt final int color,
                                            final boolean isTop) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    Activity activity = UtilsBridge.getActivityByContext(fakeStatusBar.getContext());
    if (activity == null) return;
    transparentStatusBar(activity);
    drawer.setFitsSystemWindows(false);
    setStatusBarColor(fakeStatusBar, color);
    for (int i = 0, count = drawer.getChildCount(); i < count; i++) {
        drawer.getChildAt(i).setFitsSystemWindows(false);
    }
    if (isTop) {
        hideStatusBarView(activity);
    } else {
        setStatusBarColor(activity, color, false);
    }
}