Activity设置全屏

1. AndroidManifest.xml文件,对应的Activity节点(或Application节点)设置theme

<activity
    android:name="com.example.MainActivity"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    android:label="@string/app_name" >

2. 对应Activity的onCreate函数中:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);// 这一句必须要放在最后

注:以上两种方法在Dialog上也适用

你可能感兴趣的:(android,全屏)