Java Code Examples for android.view.View#SYSTEM_UI_FLAG_HIDE_NAVIGATION

The following examples show how to use android.view.View#SYSTEM_UI_FLAG_HIDE_NAVIGATION . 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: BaseActivity.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * Make full screen in all Android version.
 */
public final void makeFullScreen() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // Hide the status bar and navigation bar.
        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
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(uiOptions);

    } else {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        getWindow().setAttributes(lp);
    }
}
 
Example 2
Source File: BarUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * Set the navigation bar's visibility.
 *
 * @param window    The window.
 * @param isVisible True to set navigation bar visible, false otherwise.
 */
public static void setNavBarVisibility(@NonNull final Window window, boolean isVisible) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    final ViewGroup decorView = (ViewGroup) window.getDecorView();
    for (int i = 0, count = decorView.getChildCount(); i < count; i++) {
        final View child = decorView.getChildAt(i);
        final int id = child.getId();
        if (id != View.NO_ID) {
            String resourceEntryName = getResNameById(id);
            if ("navigationBarBackground".equals(resourceEntryName)) {
                child.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
            }
        }
    }
    final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    if (isVisible) {
        decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~uiOptions);
    } else {
        decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | uiOptions);
    }
}
 
Example 3
Source File: TransparentActivity.java    From Rucky with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    final int flags = 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;
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    View view = getWindow().getDecorView();
    view.setSystemUiVisibility(flags);
    setContentView(R.layout.activity_transparent);
    new Handler().postDelayed(this::launchNext, 2000);
}
 
Example 4
Source File: SystemUiHiderHoneycomb.java    From KinoCast with MIT License 6 votes vote down vote up
/**
 * Constructor not intended to be called by clients. Use
 * {@link SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) {
    super(activity, anchorView, flags);

    mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
    mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if ((mFlags & FLAG_FULLSCREEN) != 0) {
        // If the client requested fullscreen, add flags relevant to hiding
        // the status bar. Note that some of these constants are new as of
        // API 16 (Jelly Bean). It is safe to use them, as they are inlined
        // at compile-time and do nothing on pre-Jelly Bean devices.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
        // If the client requested hiding navigation, add relevant flags.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
}
 
Example 5
Source File: SubsonicActivity.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
private void applyFullscreen() {
	fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false);
	if(fullScreen || isTv()) {
		// Hide additional elements on higher Android versions
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
					View.SYSTEM_UI_FLAG_FULLSCREEN |
					View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

			getWindow().getDecorView().setSystemUiVisibility(flags);
		} else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			getWindow().requestFeature(Window.FEATURE_NO_TITLE);
		}
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}
}
 
Example 6
Source File: Util.java    From DMusic with Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏状态栏&&导航栏
 */
public static void hideSystemUI(Activity activity, View... views) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // 4.1 above API level 16
        int uist = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            uist |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }
        View decorView = activity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(uist);
        // Some views can setFitsSystemWindows(true), setPadding()
        setFitsPadding(0, getStatusBarHeight(activity), getNavigationBarHeight(activity), 0, views);
    } else {
        WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        activity.getWindow().setAttributes(attrs);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
}
 
Example 7
Source File: ImmersiveUtils.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
public static void toggleHideyBar(Activity activity, boolean onResume) {

        int newUiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();

        if (onResume) {

            applyImmersiveMode(activity);

        } else {
            newUiOptions ^= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            newUiOptions ^= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
            newUiOptions ^= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
            newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

            newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
            newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE;
            newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            activity.getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
        }
    }
 
Example 8
Source File: BarUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 设置 Navigation Bar 是否可见
 * @param window    {@link Window}
 * @param isVisible 是否显示 Navigation Bar
 * @return {@code true} success, {@code false} fail
 */
public static boolean setNavBarVisibility(final Window window, final boolean isVisible) {
    if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final ViewGroup decorView = (ViewGroup) window.getDecorView();
        for (int i = 0, count = decorView.getChildCount(); i < count; i++) {
            final View child = decorView.getChildAt(i);
            final int id = child.getId();
            if (id != View.NO_ID) {
                String resourceEntryName = Resources.getSystem().getResourceEntryName(id);
                if ("navigationBarBackground".equals(resourceEntryName)) {
                    child.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
                }
            }
        }
        final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        if (isVisible) {
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~uiOptions);
        } else {
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | uiOptions);
        }
        return true;
    }
    return false;
}
 
Example 9
Source File: ArticleCollectionActivity.java    From aard2-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSystemUiVisibilityChange(int visibility) {
    if (isFinishing()) {
        return;
    }
    final View decorView = getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    boolean isHideNavigation =
            ((uiOptions | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == uiOptions);
     if (!isHideNavigation) {
        setFullScreenPref(false);
    }
}
 
Example 10
Source File: SubsonicActivity.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
private void applyFullscreen() {
    fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false);
    if (fullScreen) {
        int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_FULLSCREEN |
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        getWindow().getDecorView().setSystemUiVisibility(flags);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}
 
Example 11
Source File: BasicImmersiveModeFragment.java    From android-BasicImmersiveMode with Apache License 2.0 5 votes vote down vote up
/**
 * Detects and toggles immersive mode.
 */
public void toggleHideyBar() {
    // BEGIN_INCLUDE (get_current_ui_flags)
    // The UI options currently enabled are represented by a bitfield.
    // getSystemUiVisibility() gives us that bitfield.
    int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;
    // END_INCLUDE (get_current_ui_flags)
    // BEGIN_INCLUDE (toggle_ui_flags)
    boolean isImmersiveModeEnabled =
            ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
    if (isImmersiveModeEnabled) {
        Log.i(TAG, "Turning immersive mode mode off. ");
    } else {
        Log.i(TAG, "Turning immersive mode mode on.");
    }

    // Immersive mode: Backward compatible to KitKat (API 19).
    // Note that this flag doesn't do anything by itself, it only augments the behavior
    // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
    // all three flags are being toggled together.
    // This sample uses the "sticky" form of immersive mode, which will let the user swipe
    // the bars back in again, but will automatically make them disappear a few seconds later.
    newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
    //END_INCLUDE (set_ui_flags)
}
 
Example 12
Source File: MainActivity.java    From wearabird with MIT License 5 votes vote down vote up
private void hideSystemUI() {
	int windowVisibility = 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;

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
		windowVisibility |= View.SYSTEM_UI_FLAG_IMMERSIVE;
	}

	getWindow().getDecorView().setSystemUiVisibility(windowVisibility);
}
 
Example 13
Source File: NavigationBarUtil.java    From UIWidget with Apache License 2.0 5 votes vote down vote up
/**
 * 是否隐藏状态栏
 *
 * @param window Window对象
 * @return 是否隐藏
 */
public static boolean isHideNavigationBar(Window window) {
    if (window == null) {
        return false;
    }
    return (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
            == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
}
 
Example 14
Source File: SystemUiHelperImplICS.java    From turbo-editor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected int createHideFlags() {
    int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
        flag |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    return flag;
}
 
Example 15
Source File: Presenter.java    From react-native-navigation with MIT License 5 votes vote down vote up
private void applyNavigationBarVisibility(NavigationBarOptions options) {
    View decorView = activity.getWindow().getDecorView();
    int flags = decorView.getSystemUiVisibility();
    boolean defaultVisibility = (flags & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0;
    int hideNavigationBarFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    if (options.isVisible.get(defaultVisibility)) {
        flags &= ~hideNavigationBarFlags;
    } else {
        flags |= hideNavigationBarFlags;
    }
    decorView.setSystemUiVisibility(flags);
}
 
Example 16
Source File: GamePadActivity.java    From bombsquad-remote-android with Apache License 2.0 5 votes vote down vote up
@TargetApi(19)
private void _setImmersiveMode() {
  int vis = 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;
  if (mGLView.getSystemUiVisibility() != vis) {
    mGLView.setSystemUiVisibility(vis);
  }
}
 
Example 17
Source File: ScreenUtils.java    From MaoWanAndoidClient with Apache License 2.0 5 votes vote down vote up
public static void hideBottomUIMenu(Context context) {
    //隐藏虚拟按键,并且全屏
    if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
        View v = ((Activity) context).getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else if (Build.VERSION.SDK_INT >= 19) {
        //for new api versions.
        View decorView = ((Activity) context).getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }
}
 
Example 18
Source File: ActivityContentVideoViewEmbedder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressLint("InlinedApi")
public void setSystemUiVisibility(boolean enterFullscreen) {
    View decor = mActivity.getWindow().getDecorView();
    if (enterFullscreen) {
        mActivity.getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }

    int systemUiVisibility = decor.getSystemUiVisibility();
    int flags = 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;
    if (enterFullscreen) {
        systemUiVisibility |= flags;
    } else {
        systemUiVisibility &= ~flags;
    }
    decor.setSystemUiVisibility(systemUiVisibility);
}
 
Example 19
Source File: CaptureHighSpeedVideoMode.java    From Android-Slow-Motion-Camera2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture);
    mRecButtonVideo = (ImageButton) view.findViewById(R.id.video_record);
    mRecButtonVideo.setOnClickListener(this);
    view.findViewById(R.id.info).setOnClickListener(this);
    View decorView = getActivity().getWindow().getDecorView();
    getActivity().getWindow().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#000000")));
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(uiOptions);

}
 
Example 20
Source File: SystemUiHiderHoneycomb.java    From react-native-3d-model-view with MIT License 5 votes vote down vote up
/**
 * Constructor not intended to be called by clients. Use
 * {@link SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView,
		int flags) {
	super(activity, anchorView, flags);

	mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
	mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
	mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

	if ((mFlags & FLAG_FULLSCREEN) != 0) {
		// If the client requested fullscreen, add flags relevant to hiding
		// the status bar. Note that some of these constants are new as of
		// API 16 (Jelly Bean). It is safe to use them, as they are inlined
		// at compile-time and do nothing on pre-Jelly Bean devices.
		mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
		mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
				| View.SYSTEM_UI_FLAG_FULLSCREEN;
	}

	if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
		// If the client requested hiding navigation, add relevant flags.
		mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
		mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
				| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
		mTestFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
	}
}