Java Code Examples for android.view.View#setSystemUiVisibility()

The following examples show how to use android.view.View#setSystemUiVisibility() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Enables the fullscreen immersive mode. Only works on Kitkat and above. Also start a listener
 * in case the fullscreen mode is deactivated from the settings, so the game layout has to redraw.
 */
private void showOrHideNavBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        View decorView = getWindow().getDecorView();

        if (prefs.getSavedImmersiveMode()) {
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        } else {
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }
}
 
Example 2
private void mkFull() {

        if (book==null || !book.getFlag(FULLSCREEN, true)) return;
//        findViewById(R.id.fullscreen_no_button).setVisibility(View.VISIBLE);
//        findViewById(R.id.fullscreen_button).setVisibility(View.GONE);

        View decorView = getWindow().getDecorView();
        // Hide the status bar.
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE;
        decorView.setSystemUiVisibility(uiOptions);
    }
 
Example 3
Source Project: imsdk-android   File: MeiZuStatusUtils.java    License: MIT License 5 votes vote down vote up
/**
 * 设置状态栏颜色
 *
 * @param view
 * @param dark
 */
private static void setStatusBarDarkIcon(View view, boolean dark) {
    int oldVis = view.getSystemUiVisibility();
    int newVis = oldVis;
    if (dark) {
        newVis |= SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        newVis &= ~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (newVis != oldVis) {
        view.setSystemUiVisibility(newVis);
    }
}
 
Example 4
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ステータスバーを消す
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    );

    mManager = (MediaProjectionManager) getSystemService(MEDIA_PROJECTION_SERVICE);
}
 
Example 5
@SuppressLint("InlinedApi")
void setImmersiveSticky() {
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
 
Example 6
Source Project: react-native-navigation   File: Presenter.java    License: MIT License 5 votes vote down vote up
private void mergeTextColorScheme(TextColorScheme scheme) {
    if (!scheme.hasValue() || Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
    final View view = activity.getWindow().getDecorView();
    if (scheme == TextColorScheme.Dark) {
        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    } else {
        clearDarkTextColorScheme(view);
    }
}
 
Example 7
Source Project: sandriosCamera   File: SandriosCameraActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    cameraController = createCameraController(this, this);
    cameraController.onCreate(savedInstanceState);

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    int defaultOrientation = Utils.getDeviceDefaultOrientation(this);

    if (defaultOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        deviceDefaultOrientation = CameraConfiguration.ORIENTATION_LANDSCAPE;
    } else if (defaultOrientation == Configuration.ORIENTATION_PORTRAIT) {
        deviceDefaultOrientation = CameraConfiguration.ORIENTATION_PORTRAIT;
    }

    View decorView = getWindow().getDecorView();
    if (Build.VERSION.SDK_INT > 15) {
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
    }

    setContentView(R.layout.generic_camera_layout);

    previewContainer = findViewById(R.id.previewContainer);
    userContainer = findViewById(R.id.userContainer);

    onProcessBundle(savedInstanceState);
    setUserContent();
}
 
Example 8
Source Project: pandora   File: ViewKnife.java    License: Apache License 2.0 5 votes vote down vote up
public static void transStatusBar(@NonNull Window window) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View view = window.getDecorView();
        if (view != null) {
            view.setSystemUiVisibility(view.getSystemUiVisibility() | 1280);
        }
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}
 
Example 9
Source Project: Ariana   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideStatusbar(Activity context) {
    if (Build.VERSION.SDK_INT < 16) {
        context.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        View decorView = context.getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
    }
}
 
Example 10
public static void windowFocusChange(final Activity context, boolean hasFocus, View decorView) {
    if (hasFocus) {
        if (Build.VERSION.SDK_INT >= 19) {
            decorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        } else {
            decorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN);
        }
    } else {
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    context.finish();
                } catch (Exception e) {
                    //
                }
            }
        }, 1000);
    }
}
 
Example 11
/** Toggle whether the system UI (status bar / system bar) is visible.
 *  This also toggles the action bar visibility.
 * @param show True to show the system UI, false to hide it.
 */
void setSystemUiVisible(boolean show) {
    mSystemUiVisible = show;

    Window window = getActivity().getWindow();
    WindowManager.LayoutParams winParams = window.getAttributes();
    View view = getView();
    ActionBar actionBar = getActivity().getActionBar();

    if (show) {
        // Show status bar (remove fullscreen flag)
        window.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Show system bar
        view.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
        // Show action bar
        actionBar.show();
    } else {
        // Add fullscreen flag (hide status bar)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Hide system bar
        view.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        // Hide action bar
        actionBar.hide();
    }
    window.setAttributes(winParams);
}
 
Example 12
Source Project: hipda   File: BaseActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSessionId = UUID.randomUUID().toString();

    try {
        if (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT == HiSettingsHelper.getInstance().getScreenOrietation()) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE == HiSettingsHelper.getInstance().getScreenOrietation()) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
        }
    } catch (Exception ignored) {
        //avoid android 8.0 bug
    }

    int theme = HiUtils.getThemeValue(this,
            HiSettingsHelper.getInstance().getActiveTheme(),
            HiSettingsHelper.getInstance().getPrimaryColor());
    setTheme(theme);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && HiSettingsHelper.getInstance().isNavBarColored()) {
        getWindow().setNavigationBarColor(ColorHelper.getColorPrimary(this));
        View view = getWindow().getDecorView();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (theme == R.style.ThemeLight_White) {
                view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            } else {
                view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            }
        }
    }
}
 
Example 13
Source Project: V2EX   File: StatusBarUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void setTranslucentStatusBar(Activity activity){
    Window window = activity.getWindow();
    View view = window.getDecorView();
    int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    view.setSystemUiVisibility(option);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(Color.TRANSPARENT);
    window.setNavigationBarColor(Color.TRANSPARENT);
}
 
Example 14
Source Project: PicKing   File: PicDialog.java    License: Apache License 2.0 5 votes vote down vote up
public PicDialog(Context context) {
    super(context, R.style.AppNoActionBarTheme);
    setOwnerActivity((Activity) context);
    setContentView(R.layout.dialog_pic);

    StatusBarUtil.MIUISetStatusBarLightMode(getOwnerActivity(), true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View decorView = getWindow().getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    ButterKnife.bind(this);

    if ((boolean) SPUtils.get(getContext(), AppConfig.click_to_back, false))
        photoDraweeView.setOnViewTapListener(new OnViewTapListener() {
            @Override
            public void onViewTap(View view, float x, float y) {
                dismiss();
            }
        });

    photoDraweeView.setAllowParentInterceptOnEdge(false);
    photoDraweeView.setEnableDraweeMatrix(false);

    for (AppCompatImageButton imageButton : imageButtons)
        imageButton.setOnClickListener(this);

    getWindow().setWindowAnimations(R.style.dialogStyle);

    behavior = BottomSheetBehavior.from(findViewById(R.id.bottom_view));
}
 
Example 15
private void mkReg() {

//        findViewById(R.id.fullscreen_button).setVisibility(View.VISIBLE);
//        findViewById(R.id.fullscreen_no_button).setVisibility(View.GONE);

        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(uiOptions);
    }
 
Example 16
protected void showSystemUI() {
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
 
Example 17
Source Project: LauncherTV   File: Launcher.java    License: Apache License 2.0 5 votes vote down vote up
private void setFullScreen() {
	try {
		if (Build.VERSION.SDK_INT < 19) {
			getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
					WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
			);
		} else {
			View decorView = getWindow().getDecorView();

			int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
					| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
					| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
					| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
					| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
					| View.SYSTEM_UI_FLAG_IMMERSIVE;

			decorView.setSystemUiVisibility(uiOptions);

			getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
					WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
			);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 18
Source Project: LQRBiliBlili   File: SystemUiVisibilityUtil.java    License: MIT License 4 votes vote down vote up
public static void clearFlags(View view, int flags) {
    view.setSystemUiVisibility(view.getSystemUiVisibility() & ~flags);
}
 
Example 19
Source Project: WanAndroid   File: CommonUtils.java    License: MIT License 4 votes vote down vote up
/**
 * 显示虚拟按键
 */
public static void showBottomUIMenu(Activity activity) {
    View decorView = activity.getWindow().getDecorView();
    decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}
 
Example 20
Source Project: android_9.0.0_r45   File: DreamService.java    License: Apache License 2.0 4 votes vote down vote up
private void applySystemUiVisibilityFlags(int flags, int mask) {
    View v = mWindow == null ? null : mWindow.getDecorView();
    if (v != null) {
        v.setSystemUiVisibility(applyFlags(v.getSystemUiVisibility(), flags, mask));
    }
}