Java Code Examples for android.view.View#SYSTEM_UI_FLAG_IMMERSIVE_STICKY

The following examples show how to use android.view.View#SYSTEM_UI_FLAG_IMMERSIVE_STICKY . 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
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 2
private void changeSystemUiVisibilityLandscape() {
    WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    if (windowManager == null) {
        return;
    }

    int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

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

    videoViewAccessor.attachVideoView().setSystemUiVisibility(flag);
}
 
Example 3
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature((Window.FEATURE_NO_TITLE));
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.hide();
    };

    View decorView= getWindow().getDecorView();
    int uiOptions=View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
            View.SYSTEM_UI_FLAG_FULLSCREEN |
            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            ;
    decorView.setSystemUiVisibility(uiOptions);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mGLView = new MyGLSurfaceView(this);
    setContentView(mGLView);
}
 
Example 4
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setHideyBar() {
    Log.i(LOG_TAG, "Activating immersive mode");
    int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;

    if(Build.VERSION.SDK_INT >= 14){
        newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    if(Build.VERSION.SDK_INT >= 16){
        newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    if(Build.VERSION.SDK_INT >= 18){
        newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}
 
Example 5
Source Project: mini2Dx   File: AndroidMini2DxGame.java    License: Apache License 2.0 6 votes vote down vote up
@TargetApi(19)
@Override
public void useImmersiveMode(boolean use) {
	if (!use || getVersion() < Build.VERSION_CODES.KITKAT)
		return;

	View view = getWindow().getDecorView();
	try {
		Method m = View.class.getMethod("setSystemUiVisibility", int.class);
		int code = 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;
		m.invoke(view, code);
	} catch (Exception e) {
		log("AndroidApplication", "Can't set immersive mode", e);
	}
}
 
Example 6
Source Project: UIWidget   File: NavigationBarUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏导航栏
 *
 * @param window Window 对象
 * @param isHide 是否隐藏
 */
public static void hideNavigationBar(Window window, boolean isHide) {
    if (window == null) {
        return;
    }
    //防止系统栏隐藏时内容区域大小发生变化
    int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | window.getDecorView().getSystemUiVisibility();
    if (isHide) {
        if (!isHideNavigationBar(window)) {
            uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }
    } else {
        if (isHideNavigationBar(window)) {
            uiFlags ^= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    ^ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }
    }
    uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    window.getDecorView().setSystemUiVisibility(uiFlags);
}
 
Example 7
@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 8
Source Project: a2cardboard   File: CordovaActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Called when view focus is changed
 */
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus && immersiveMode) {
        final 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;

        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
}
 
Example 9
private static int getExtraFullscreenUIFlags() {
    int flags = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    return flags;
}
 
Example 10
Source Project: BaseProject   File: ViewUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideNavigation(Window curWindow) {
        if (curWindow != null && Build.VERSION.SDK_INT >= 19) {
            //隐藏Navigation bar
            WindowManager.LayoutParams layoutParams = curWindow.getAttributes();
            layoutParams.systemUiVisibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            ;
//        layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
            curWindow.setAttributes(layoutParams);
//            View decorView = curWindow.getDecorView();
//            if (decorView != null) {
//                int oldUiFlags = decorView.getSystemUiVisibility();
//                int uiFlags =
//                        oldUiFlags |
//                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
////                            | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
//                                | View.SYSTEM_UI_FLAG_IMMERSIVE
//                                | 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;
//                decorView.setSystemUiVisibility(uiFlags);
//            }
        }
    }
 
Example 11
@Override
public void toggleSystemUiVisibility() {
    Window activityWindow = ((Activity) getContext()).getWindow();
    View decorView = activityWindow.getDecorView();
    int newUiOptions = decorView.getSystemUiVisibility();
    newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(newUiOptions);
}
 
Example 12
private void hideSystemUI() {

        int flags = 0;

        toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(
                new AccelerateInterpolator()).start();

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN;
        }

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

        getWindow().getDecorView().setSystemUiVisibility(flags);

        hideFavorite();
    }
 
Example 13
private static int getExtraFullscreenUIFlags() {
    int flags = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    return flags;
}
 
Example 14
@Override
public void onClick(View view) {
    View decorView = getActivity().getWindow().getDecorView();
    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;
    switch (view.getId()) {
        case R.id.info: {
            Activity activity = getActivity();
            if (null != activity) {
                new AlertDialog.Builder(activity)
                        .setMessage(R.string.intro_message)
                        .setPositiveButton(android.R.string.ok, null)
                        .show();

            }
            break;
        }
        case R.id.video_record: {
            decorView.setSystemUiVisibility(uiOptions);
            if (mIsRecordingVideo) {
                stopRecordingVideo();
            } else {
                startRecordingVideo();
            }
            break;
        }
    }
}
 
Example 15
private void hideNavigationBar() {
    View decorView = getWindow().getDecorView();
    // Hide both the navigation bar and the status bar.
    // SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
    // a general rule, you should design your app to hide the status bar whenever you
    // hide the 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;

    decorView.setSystemUiVisibility(uiOptions);
}
 
Example 16
@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 17
Source Project: DKVideoPlayer   File: VideoView.java    License: Apache License 2.0 5 votes vote down vote up
private void showSysBar(ViewGroup decorView) {
    int uiOptions = decorView.getSystemUiVisibility();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        uiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    decorView.setSystemUiVisibility(uiOptions);
    getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
 
Example 18
public void setupWindowVisibilityFlags()
{
    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;
    //
    final View decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
    {

        @Override
        public void onSystemUiVisibilityChange (int visibility)
        {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
            {
                decorView.setSystemUiVisibility(flags);
            }
        }
    });
    //
    decorView.setSystemUiVisibility(flags);
    //
    // disable the lock screen when the app is running
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
 
Example 19
Source Project: WanAndroid   File: CommonUtils.java    License: MIT License 4 votes vote down vote up
/**
 * 隐藏虚拟按键,并且全屏
 */
public static void hideBottomUIMenu(Activity activity) {
    View decorView = activity.getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
}
 
Example 20
Source Project: HomeMirror   File: MirrorActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mirror);
    mConfigSettings = new ConfigurationSettings(this);
    AlarmReceiver.startMirrorUpdates(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } 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
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_IMMERSIVE;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mBirthdayText = (TextView) findViewById(R.id.birthday_text);
    mDayText = (TextView) findViewById(R.id.day_text);
    mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
    mHelloText = (TextView) findViewById(R.id.hello_text);
    mWaterPlants = findViewById(R.id.water_plants);
    mGroceryList = findViewById(R.id.grocery_list);
    mBikeTodayText = (TextView) findViewById(R.id.can_bike);
    mStockText = (TextView) findViewById(R.id.stock_text);
    mMoodText = (TextView) findViewById(R.id.mood_text);
    mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
    mNewsHeadline = (TextView) findViewById(R.id.news_headline);
    mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
    mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
    mCountdownText = (TextView) findViewById(R.id.countdown_text);

    if (mConfigSettings.invertXKCD()) {
        //Negative of XKCD image
        float[] colorMatrixNegative = {
                -1.0f, 0, 0, 0, 255, //red
                0, -1.0f, 0, 0, 255, //green
                0, 0, -1.0f, 0, 255, //blue
                0, 0, 0, 1.0f, 0 //alpha
        };
        ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
        mXKCDImage.setColorFilter(colorFilterNegative); // not inverting for now
    }

    setViewState();
}