您的位置:首页 > 移动开发 > Android开发

android 学习五 设置应用程序全屏(没有状态栏和标题栏)

2011-11-12 00:25 363 查看
去除android应用程序的标题栏和状态栏有两种方法:

一种是在java文件中使用如下代码可以实现全屏

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//hide the status bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
//hide the title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
}
如上注释表明哪一部分隐藏工具栏,哪一部分隐藏标题栏

二种是在AndroidManifest.xml 中进行配置如下:

<application

android:icon="@drawable/ic_launcher"

android:label="@string/app_name" >

<activity

android:label="@string/app_name"

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

android:name=".MySchoolAssistantActivity" >

<intent-filter >

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

当然可以更加直接的将 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

注意:一个app应用应该统一风格,如果一个界面采用的全屏的方式实现,则其他界面也需要采用全屏的方式实现。所以对于这项需求来说更加适合在xml文件中进行配置
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: