Splash隐藏状态栏和导航栏
程序员文章站
2022-03-27 12:06:33
/** * 隐藏状态栏和导航栏 */public void hideBar() { int uiFlags = 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...
/**
* 隐藏状态栏和导航栏
*/
public void hideBar() {
int uiFlags = 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 (android.os.Build.VERSION.SDK_INT >= 19) {
uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE;//0x00001000; // SYSTEM_UI_FLAG_IMMERSIVE_STICKY: hide
} else {
uiFlags |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
try {
getWindow().getDecorView().setSystemUiVisibility(uiFlags);
} catch (Exception e) {
}
}
设置无标题:
requestWindowFeature(Window.FEATURE_NO_TITLE);
设置属性:
WindowManager.LayoutParams lp = getWindow().getAttributes();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
getWindow().setAttributes(lp);
设置背景图片
int id = getBackgroundDrawableId();
if (id > 0) {
getWindow().getDecorView().setBackground(getDrawable(getBackgroundDrawableId()));//设置背景
}
protected int getBackgroundDrawableId() {
return R.mipmap.splash_bg; //获取splash窗口背景资源
}
本文地址:https://blog.csdn.net/weixin_41422638/article/details/107175224
上一篇: 洗衣机还搁那没修