android去标题栏与全屏,动态全屏与退出全屏

1在代码中去标题栏

requestWindowFeature(Window.FEATURE_NO_TITLE);

在代码中设置全屏

getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN);

2在配置文件中去标题栏

在manefinest的所在的Activity配置中加上

android:theme="@android:style/Theme.NoTitleBar"

在配置文件中设置全屏

在manefinest的所在的Activity配置中加上

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"


2动态的全屏与退出全屏

在程序中动态的设置全屏

WindowManager.LayoutParams attrs = getWindow().getAttributes();  

attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;    

getWindow().setAttributes(attrs);    

getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

在程序中动态的退出全屏

WindowManager.LayoutParams attrs = getWindow().getAttributes();    

attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);   

getWindow().setAttributes(attrs);    

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);  






你可能感兴趣的:(android去标题栏与全屏,动态全屏与退出全屏)