1. 程式人生 > >Android設定全屏顯示

Android設定全屏顯示

主要有兩種方式:

第一種辦法: 程式碼中設定:

requestWindowFeature(Window.FEATURE_NO_TITLE);// 隱藏標題

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

WindowManager.LayoutParams.FLAG_FULLSCREEN);// 設定全屏

setContentView(R.layout.activity_main);

注意:setContentView一定要寫在設定全屏後邊

第二種辦法:AndroidManifest.xml檔案中設定

<

application

android:allowBackup="true"

android:icon="@drawable/icon"

android:label="@string/app_name"

android:theme="@style/AppTheme"

android:name="com.scwindow.utility.CrashApplication" >


在res檔案下的values檔案下styles.xml檔案中,定義一下AppTheme

<!-- Application theme. -->

<stylename="AppTheme" parent

="AppBaseTheme">

<!-- All customizations that are NOT specific to a particular API-level can go here. -->

<itemname="android:windowNoTitle">true</item>

<itemname="android:windowFullscreen">true</item>

<itemname="android:windowIsTranslucent">true</item>

</

style>