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

The following examples show how to use android.view.View#setSystemUiVisibility() . 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: GameManager.java    From Simple-Solitaire with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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
Source File: ReaderActivity.java    From BookyMcBookface with GNU General Public License v3.0 6 votes vote down vote up
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 File: PermissionReceiverActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@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 4
Source File: Launcher.java    From LauncherTV with 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 5
Source File: CameraActivity.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
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 6
Source File: ReaderActivity.java    From BookyMcBookface with GNU General Public License v3.0 5 votes vote down vote up
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 7
Source File: PicDialog.java    From PicKing with 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 8
Source File: StatusBarUtil.java    From V2EX with 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 9
Source File: BaseActivity.java    From hipda with 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 10
Source File: ContentFragment.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
/** 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 11
Source File: NFCReaderX.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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 12
Source File: Utils.java    From Ariana with 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 13
Source File: ViewKnife.java    From pandora with 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 14
Source File: SandriosCameraActivity.java    From sandriosCamera with 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 15
Source File: Presenter.java    From react-native-navigation with 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 16
Source File: NearbyNativeActivity.java    From connectivity-samples with Apache License 2.0 5 votes vote down vote up
@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 17
Source File: MeiZuStatusUtils.java    From imsdk-android with 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 18
Source File: SystemUiVisibilityUtil.java    From LQRBiliBlili with MIT License 4 votes vote down vote up
public static void clearFlags(View view, int flags) {
    view.setSystemUiVisibility(view.getSystemUiVisibility() & ~flags);
}
 
Example 19
Source File: CommonUtils.java    From WanAndroid with 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 File: DreamService.java    From android_9.0.0_r45 with 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));
    }
}