3个主要方法:
private boolean isStatus=false;
private boolean isshowStatus=true;
private boolean isFullScresn=false;
//沉浸式
public void setStatus(boolean status) {
isStatus = status;
if (isStatus==true){
if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
}
public void setIsshowStatus(boolean isStatus){
isshowStatus=isStatus;
if (isshowStatus){
getSupportActionBar().show();
}else {
getSupportActionBar().hide();
}
}
public void setFullScresn(Boolean isdullScresn){
isFullScresn=isdullScresn;
if (isFullScresn){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
哪里沉浸哪里调用:
setStatus(true);
setIsshowStatus(false);
setFullScresn(true);
本文介绍了如何通过三个方法实现Android应用中的沉浸式界面效果:设置状态栏透明、控制ActionBar显示和全屏模式。这些方法使用了WindowManager.LayoutParams的特定标志来达到预期的效果。
810

被折叠的 条评论
为什么被折叠?



