本文整理汇总了Java中android.view.View.SYSTEM_UI_FLAG_IMMERSIVE属性的典型用法代码示例。如果您正苦于以下问题:Java View.SYSTEM_UI_FLAG_IMMERSIVE属性的具体用法?Java View.SYSTEM_UI_FLAG_IMMERSIVE怎么用?Java View.SYSTEM_UI_FLAG_IMMERSIVE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.View
的用法示例。
在下文中一共展示了View.SYSTEM_UI_FLAG_IMMERSIVE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hideSystemUI
public static void hideSystemUI(@NonNull final Activity activity, final boolean immediate, final int delayMs) {
View decorView = activity.getWindow().getDecorView();
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
int uiState = 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
if (Util.SDK_INT > 18) {
uiState |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_IMMERSIVE;
} else {
final Handler handler = new Handler();
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if (visibility == View.VISIBLE) {
Runnable runnable = new Runnable() {
@Override
public void run() {
hideSystemUI(activity, false);
}
};
if(immediate){
handler.post(runnable);
}else{
handler.postDelayed(runnable, delayMs);
}
}
}
});
}
decorView.setSystemUiVisibility(uiState);
}
示例2: toggleHideyBar
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);
}
}
示例3: createHideFlags
@Override
protected int createHideFlags() {
int flag = super.createHideFlags();
if (mLevel == SystemUiHelper.LEVEL_IMMERSIVE) {
// If the client requested immersive mode, and we're on Android 4.4
// or later, add relevant flags. Applying HIDE_NAVIGATION without
// IMMERSIVE prevents the activity from accepting all touch events,
// so we only do this on Android 4.4 and later (where IMMERSIVE is
// present).
flag |= ((mFlags & SystemUiHelper.FLAG_IMMERSIVE_STICKY) != 0)
? View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
: View.SYSTEM_UI_FLAG_IMMERSIVE;
}
return flag;
}
示例4: setUiVisibilityKitKat
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setUiVisibilityKitKat(boolean isVisible) {
int flags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
if (!isVisible) {
flags |= View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE;
}
viewPager.setSystemUiVisibility(flags);
}
示例5: setFullScreen
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();
}
}
示例6: showSystemBar
protected void showSystemBar(boolean show) {
if (mSystemBarShowing == show) return;
mSystemUiVisibility = mPlayerView.getSystemUiVisibility();
if (PlayerConfig.hasHackedFullScreen()) {
final int STATUS_BAR_GONE = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 ? 0x00000004 : 0x000008);
if (show)
mSystemUiVisibility &= ~STATUS_BAR_GONE;
else
mSystemUiVisibility |= STATUS_BAR_GONE;
manualVisibilityChange=true;
mPlayerView.setSystemUiVisibility(mSystemUiVisibility);
mSystemBarGone = !show;
} else {
int systemUiFlag = View.SYSTEM_UI_FLAG_LOW_PROFILE;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { /* ICS and less */
if (show)
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
else
mWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else { /* JB and more */
systemUiFlag |= 0x00000004 /* View.SYSTEM_UI_FLAG_FULLSCREEN */;
}
if (show) {
mSystemUiVisibility &= ~systemUiFlag;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
}
else {
mSystemUiVisibility |= systemUiFlag;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
mSystemUiVisibility |= View.SYSTEM_UI_FLAG_IMMERSIVE;
}
mPlayerView.setSystemUiVisibility(mSystemUiVisibility);
manualVisibilityChange=true;
mSystemBarGone = false;
if (PlayerConfig.canSystemBarHide()) {
if (!show)
mHandler.sendEmptyMessageDelayed(MSG_HIDE_SYSTEM_BAR, 1000);
}
}
mSystemBarShowing = show;
}
示例7: onResume
@Override
protected void onResume() {
super.onResume();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY ;
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
mSounds = App.getInstance(this).getSoundEffects();
unpause();
updateScores();
mSounds.playBGMusic();
}