在Android中设置全屏的方式大致有两种,一种是通过代码控制,一种是通过theme样式配置。
那如何判断一个Activity是不是全屏呢?
可以有以下几种方式:
1.判断window flag属性(代码控制)
if ( (activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
== WindowManager.LayoutParams.FLAG_FULLSCREEN) {
return true;
}
2.判断SystemUiVisibility属性(代码控制)
if((activity.getWindow().getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_FULLSCREEN)
== View.SYSTEM_UI_FLAG_FULLSCREEN){
activity.getWindow().getDecorView().setSystemUiVisibility();
return true;
}
3.判断theme样式中的android:windowFullscreen属性值(theme样式)
TypedValue typedValue = new TypedValue();
activity.getTheme().obtainStyledAttributes(new int[]{android.R.attr.windowFullscreen}).getValue(0, typedValue);
if (typedValue.type == TypedValue.TYPE_INT_BOOLEAN) {
if (typedValue.data != 0) {
return true;
}
}
网友评论