当前位置: 代码迷 >> 综合 >> android 沉浸式状态栏+状态栏颜色反转
  详细解决方案

android 沉浸式状态栏+状态栏颜色反转

热度:88   发布时间:2023-10-26 05:19:33.0

/**
     * 系统statusbar条颜色反转,背景变白色,字体变黑色
     * 如果activity顶到屏幕上面去了,则要在布局添加android:fitsSystemWindows="true"
     */
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    private void setWhiteStatusBar(){
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | 0x00002000);

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

  相关解决方案