目录

  • 使用actionBarhide方法
  • 在布局加载之前隐藏
  • 在AndroidManifestxml中配置
  • 高度定制在stylesxml中修改

1. 使用actionBar.hide()方法

public class MainActivity extends Activity {    @Override    public void onCreate(Bundle savedInstanceState){        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        ActionBar actionBar = getSupportActionBar();        if (actionBar != null) {            actionBar.hide(); //隐藏标题栏        }    }}

2. 在布局加载之前隐藏

public class MainActivity extends Activity {    @Override    public void onCreate(Bundle savedInstanceState){        super.onCreate(savedInstanceState);        this.requestWindowFeature(Window.FEATURE_NO_TITLE);        setContentView(R.layout.activity_main);    }}

3. 在AndroidManifest.xml中配置

<application    android:allowBackup="true"    android:icon="@drawable/ic_launcher"    android:label="@string/app_name"    android:theme="@android:style/Theme.NoTitleBar" >application>
<activity    android:name=".MainActivity"    android:label="@string/app_name"    android:theme="@android:style/Theme.NoTitleBar" >activity>

4. 高度定制——在styles.xml中修改

方法a 打开res/values/styles.xml,将“AppTheme”的值更改为以下代码:

<resources>        <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">    -- Customize your theme here. -->    ...    style>resources>

这样所有界面的标题栏都消失了。其中Theme.AppCompat.Light.NoActionBar表示淡色主题,你也可以换用深色主题的:Theme.AppCompat.NoActionBar(注意暗色主题可不是“Dark”,而是把“Light”一词去掉)

方法b 或者在styles.xml中新自定义一个主题

<resources>    <style name="NoTheme" parent="AppTheme">        <item name="android:windowNoTitle">trueitem>    style>resources>

该方法可以很方便地对主题进行定制


参考:

  1. 郭霖《第一行代码 第二版》p409
  2. 三种去除Android标题栏的方法 - CSDN博客 http://blog.csdn.net/djl461260911/article/details/39373305

更多相关文章

  1. android遮罩层
  2. android asset中 zip包解压sdcard
  3. Android(安卓)menu使用
  4. Android(安卓)强制设置横屏或竖屏 设置全屏
  5. Android分享笔记(5) Android(安卓)与 JS 交互
  6. android 4.2里面增加遥控器按键的方法
  7. Android获取在桌面上有图标的app列表的方法
  8. android 连接webservice
  9. Android(安卓)JNI入门第三篇――jni头文件分析

随机推荐

  1. Android 标识绑定View
  2. 修改Android应用程序的默认最大内存值
  3. 【Android】getwidth和getmeasuredwidth
  4. Android(安卓)Studio 4.0 New Class 的坑
  5. android设置默认程序&清除默认设置
  6. android gps ,wifi ,基站定位集合
  7. 关于java.lang.NoSuchMethodException: [
  8. Android实现简单画图画板
  9. Android 调用intent 拍照
  10. Mac 真机调试android程序