Android全屏設置

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class FullScreenExp extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //全屏設置:
        //1.設置隱去狀態欄部分,包括電池等圖標,
        //2.無疑就是把我們應用的名字也隱去不顯示,這樣一來就全屏了
        //注意: 隱去標題(應用的名字) 此設定必須要寫在setContentView之前,否則會有異常! 
        
        //隱去電池等圖標和一切修飾部分(狀態欄部分)
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // 隱去標題欄(程序的名字) 
        this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
        
        setContentView(R.layout.main);
    }
}

 

另外:

 

設置橫豎屏也可以在AndroidManifest.xml中定義:
android:theme="@android:style/Theme.NoTitleBar" 隱去標題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 隱去狀態欄

 

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".SimpleGraph"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章