android.view.ViewGroup#setFitsSystemWindows ( )源码实例Demo

下面列出了android.view.ViewGroup#setFitsSystemWindows ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Focus   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 设置状态栏透明
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 设置内容布局属性
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        // 设置抽屉布局属性
        ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
        vg.setFitsSystemWindows(false);
        // 设置 DrawerLayout 属性
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
源代码2 项目: LLApp   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 设置状态栏透明
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 设置内容布局属性
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        // 设置抽屉布局属性
        ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
        vg.setFitsSystemWindows(false);
        // 设置 DrawerLayout 属性
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
源代码3 项目: FileManager   文件: StatusBarUtil.java
/**
 * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
 *
 * @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);
  }
}
 
源代码4 项目: HHComicViewer   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @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);
}
 
源代码5 项目: CloudReader   文件: StatusBarUtil.java
/**
 * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 * @param color        状态栏颜色值
 */
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 生成一个状态栏大小的矩形
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) {
            contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
        } else {
            // 添加 statusBarView 到布局中
            StatusBarView statusBarView = createStatusBarView(activity, color);
            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);
    }
}
 
源代码6 项目: HHComicViewer   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 设置状态栏透明
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 设置内容布局属性
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        // 设置抽屉布局属性
        ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
        vg.setFitsSystemWindows(false);
        // 设置 DrawerLayout 属性
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
源代码7 项目: NetEasyNews   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 设置状态栏透明
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 设置内容布局属性
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        // 设置抽屉布局属性
        ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
        vg.setFitsSystemWindows(false);
        // 设置 DrawerLayout 属性
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
源代码8 项目: java-n-IDE-for-Android   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout ViewGroup
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, ViewGroup drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 设置状态栏透明
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 设置内容布局属性
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        // 设置抽屉布局属性
        ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
        vg.setFitsSystemWindows(false);
        // 设置 DrawerLayout 属性
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
源代码9 项目: AndroidAnimationExercise   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @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);
}
 
源代码10 项目: MaoWanAndoidClient   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 设置状态栏透明
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 设置内容布局属性
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        // 设置抽屉布局属性
        ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
        vg.setFitsSystemWindows(false);
        // 设置 DrawerLayout 属性
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
源代码11 项目: FileManager   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @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);
}
 
源代码12 项目: FileManager   文件: StatusBarUtil.java
/**
 * 为DrawerLayout 布局设置状态栏变色
 *
 * @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);
  }
  // 生成一个状态栏大小的矩形
  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);
}
 
源代码13 项目: ByWebView   文件: StatusBarUtil.java
/**
 * 为DrawerLayout 布局设置状态栏变色
 *
 * @param activity       需要设置的activity
 * @param drawerLayout   DrawerLayout
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt 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);
}
 
源代码14 项目: FastAndroid   文件: UIStatusBarController.java
/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    drawerLayoutContentLayout.setFitsSystemWindows(false);
    drawerLayoutContentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);
}
 
源代码15 项目: APlayer   文件: StatusBarUtil.java
/**
 * 设置根布局参数
 */
private static void setRootView(Activity activity) {
  ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content))
      .getChildAt(0);
  rootView.setFitsSystemWindows(true);
  rootView.setClipToPadding(true);
}
 
源代码16 项目: AndroidAnimationExercise   文件: StatusBarUtil.java
public static void setColorForViewGroup(Activity activity, ViewGroup 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(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);
}
 
源代码17 项目: LLApp   文件: StatusBarUtil.java
/**
 * 为DrawerLayout 布局设置状态栏变色
 *
 * @param activity       需要设置的activity
 * @param drawerLayout   DrawerLayout
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt 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);
}
 
源代码18 项目: HHComicViewer   文件: StatusBarUtil.java
/**
 * 设置根布局参数
 */
private static void setRootView(Activity activity) {
    ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
    rootView.setFitsSystemWindows(true);
    rootView.setClipToPadding(true);
}
 
源代码19 项目: AndroidChromium   文件: ChromeActivity.java
/**
 * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
 * super.setContentView() before using {@link #getTabModelSelector()} or
 * {@link #getCompositorViewHolder()}.
 */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");

    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        warmupManager.transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        warmupManager.clearViewHierarchy();

        // Allow disk access for the content view and toolbar container setup.
        // On certain android devices this setup sequence results in disk writes outside
        // of our control, so we have to disable StrictMode to work. See crbug.com/639352.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
        try {
            setContentView(R.layout.main);
            if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
                ViewStub toolbarContainerStub =
                        ((ViewStub) findViewById(R.id.control_container_stub));
                toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
                toolbarContainerStub.inflate();
            }

            // It cannot be assumed that the result of toolbarContainerStub.inflate() will be
            // the control container since it may be wrapped in another view.
            ControlContainer controlContainer =
                    (ControlContainer) findViewById(R.id.control_container);

            // Inflate the correct toolbar layout for the device.
            int toolbarLayoutId = getToolbarLayoutId();
            if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) {
                controlContainer.initWithToolbar(toolbarLayoutId);
            }
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;

    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK);

    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);

    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);

    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}
 
源代码20 项目: delion   文件: ChromeActivity.java
/**
 * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
 * super.setContentView() before using {@link #getTabModelSelector()} or
 * {@link #getCompositorViewHolder()}.
 */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");

    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasBuiltOrClearViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        WarmupManager.getInstance().transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        setContentView(R.layout.main);
        if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
            ViewStub toolbarContainerStub =
                    ((ViewStub) findViewById(R.id.control_container_stub));
            toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
            toolbarContainerStub.inflate();
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;

    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK);

    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);

    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);

    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}
 
 方法所在类