本文整理汇总了Java中android.view.View.setOnSystemUiVisibilityChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.setOnSystemUiVisibilityChangeListener方法的具体用法?Java View.setOnSystemUiVisibilityChangeListener怎么用?Java View.setOnSystemUiVisibilityChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setOnSystemUiVisibilityChangeListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hideSystemUI
import android.view.View; //导入方法依赖的package包/类
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: onCreate
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fetchLEDData();
PowerManager pm = (PowerManager)getSystemService(
Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
"led");
mWakeLock.acquire();
final View decorView = getWindow().getDecorView();
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int i) {
if ((i & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
decorView.setSystemUiVisibility(uiOptions);
}
},1000);
} else {
}
}
});
}
示例3: hideDecor
import android.view.View; //导入方法依赖的package包/类
public void hideDecor() {
if (SettingValues.immersiveMode) {
final 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
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
decorView.setOnSystemUiVisibilityChangeListener(
new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility) == 0) {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_FULLSCREEN);
} 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
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
});
}
}
示例4: lightsOutMode
import android.view.View; //导入方法依赖的package包/类
public void lightsOutMode() {
lightsOutMode = true;
final View rootView = getWindow().getDecorView();
rootView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
rootView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
rootView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
MLog.d(TAG, "" + visibility);
rootView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
rootView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
}
});
}
示例5: enableImmersiveMode
import android.view.View; //导入方法依赖的package包/类
public void enableImmersiveMode(final View decorViewOfActivity) {
decorViewOfActivity.setSystemUiVisibility(getImmersiveUiVisibility());
decorViewOfActivity.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorViewOfActivity.setSystemUiVisibility(getImmersiveUiVisibility());
}
}
});
}