设置android全屏的两种方式

http://www.freehum.com/2011/06/android-fullscreen.html

设置android全屏的两种方式

一、在代码中设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.hhh.changeimage;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
 
public class ChangeImage 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);
     }

无title和全屏段代码必须在setContentView(R.layout.main) 之前,不然会报错。

二、在配置文件里修改(android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”)

1
2
3
4
5
6
7
8
< activity android:name = ".ChangeImage"
     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 >

用一的情况在应用运行后,会看到短暂的状态栏,然后才全屏,而第二种方法是不会有这种情况的。



你可能感兴趣的:(设置android全屏的两种方式)