Android 不显示标题栏和全屏的设置方法

Android 不显示标题栏和全屏的设置方法

1.在Manifest.xml中设置

不显示标题栏
android:theme="@android:style/Theme.NoTitleBar"
全屏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

2.在Manifest和Style.xml中设置

Manifest:android:theme="@style/AppTheme"

Style.xml:

<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowNoTitle">true</item>
</style>

3.在代码中实现
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

  

Android应用开发界面顶部上有灰条,用来显示项目名称。这个应用名称是可以更改的,在strings.xml中,就可以设定 <string name="app_name">应用名称</string>。如果不显示的话,加上一个语句就行了:requestWindowFeature(Window.FEATURE_NO_TITLE);

        经过实践操作具体添加位置:

        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                requestWindowFeature(Window.FEATURE_NO_TITLE);// 填充标题栏
                setContentView(R.layout.main);

        requestWindowFeature();

       这句需要在setContentView之前使用才能生效。

posted @ 2014-11-25 17:24  ℡﹏嗳つ゛  阅读(237)  评论(0)    收藏  举报