在開發(fā)中我們經(jīng)常需要把我們的應(yīng)用設(shè)置為全屏,,這里我所知道的有倆中方法,,一中是在代碼中設(shè)置,,另一種方法是在配置文件里改!
一,、在代碼中設(shè)置:
view plaincopy to clipboardprint?
package com.android.tutor; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class OpenGl_Lesson1 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //無title requestWindowFeature(Window.FEATURE_NO_TITLE); //全屏 getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN); setContentView(R.layout.main); } } package com.android.tutor; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class OpenGl_Lesson1 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //無title requestWindowFeature(Window.FEATURE_NO_TITLE); //全屏 getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN); setContentView(R.layout.main); } } 在這里要強(qiáng)調(diào)一點(diǎn),設(shè)置全屏的倆段代碼必須在setContentView(R.layout.main) 之前,,不然會(huì)報(bào)錯(cuò),。
二,、在配置文件里修改
(android:theme="@android:style/Theme.NoTitleBar.Fullscreen"):
view plaincopy to clipboardprint? <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.tutor" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".OpenGl_Lesson1" 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> <uses-sdk android:minSdkVersion="7" /> </manifest> <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.tutor" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".OpenGl_Lesson1" 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> <uses-sdk android:minSdkVersion="7" /> </manifest> 在這里我還想說明一下,用前者在我們應(yīng)用運(yùn)行后,,會(huì)看到短暫的狀態(tài)欄,,然后才全屏,而第二種方法是不會(huì)有這種情況的,,所以我建議
大家使用后者,! 謝謝~
|
|