android activity全屏

有两种方法:

1、在AndroidManifest.xml的配置文件里面的<activity>标签添加属性:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

如:

<activity
android:name="com.wangfeng.wfgogofish.ui.FirstActivity"
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>

2.在Activity的onCreate()方法中的super()和setContentView()两个方法之间加入下面两条语句:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏

如:

  @Override

    public void onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       requestWindowFeature(Window.FEATURE_NO_TITLE); //设置无标题

       getWindow().setFlags(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT);  //设置全屏  

       setContentView(R.layout.image_list_layout);

    }

 

posted @ 2014-11-25 16:26  呼啸而过  阅读(852)  评论(0编辑  收藏  举报