一般在设置Android应用全屏显示有三种方法
第一种是代码实现
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//设置无Title
requestWindowFeature(Window.FEATURE_NO_TITLE);
//设置应用全屏,必须写在setContentView方法前面!!!记得!
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
第二种是在AndroidManifest,xml清单配置文件里配置
在相应的Activity中节点中添加属性:android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 即可以设置某个Activity全屏显示。若设置成 android:theme="@android:style/Theme.NoTitleBar" 即是只是设置成无标题状态。
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.expandablelistview.MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
第三种方法是自定义全屏Theme
在style.xml文件中定义theme(如果没有style.xml,在res/values目录下创建)
<resources>
<style name="Theme.NoTitle_FullScreen">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
然后直接在AndroidManifest.xml中需要全屏显示的Activity属性中添加
android:theme="@style/Theme.NoTitle_FullScree"