android隐藏标题栏(Action Bar)
来源:互联网 发布:js随机数 不重复 编辑:程序博客网 时间:2024/05/17 06:49
由于在5.0以下Notification只能在状态栏显示,因此需要将Activity从全屏style,转为仅显示状态栏style,即隐藏标题栏。
先看一下标题栏,状态栏,导航栏的位置。
通常有四种方法隐藏标题栏。
(1)在Manifest对应的Activity设置NoTitleBar风格
android:theme="@android:style/Theme.NoTitleBar"
(2)自定义style
首先在style.xml文件里定义自己的Style
<?xml version="1.0" encoding="UTF-8" ?> <resources> <style name="titleisnull"> <item name="android:windowNoTitle">true</item> </style> </resources>
在Manifest中的指定Activity调用自定义Style
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/titleisnull">
(3)在代码中隐藏标题栏
if (getSupportActionBar() != null){ getSupportActionBar().hide();}
(4)去掉标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_main);
需要注意的是,requestWindowFeature()方法必须在setContentView()调用前使用。
但该方法也有失效的时候,原因在于对应Activity的继承。
相关的解决方案,此处不做描述,但可参照以下博文
http://blog.csdn.net/bingjianIT/article/details/51706518
顺便记录一下,Activity全屏的设置。
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
需要指出的是,标题栏(Action Bar)是Activity的一部分,全屏只是会隐藏状态栏,对标题栏无影响。
阅读全文
0 0
- android隐藏标题栏(Action Bar)
- android 去除title bar 标题栏 action bar
- 修改 Android 标题栏(Title Bar)
- Android自定义title bar(标题栏)
- Android自定义title bar(标题栏)
- android fragment向action bar添加菜单处理,隐藏等
- Android UI ActionBar功能-自动隐藏 Action Bar
- android fragment向action bar添加菜单处理,隐藏等
- 显示和隐藏动作栏(Action Bar)
- android 动作栏(Action Bar)
- android 动作栏(Action Bar)
- Action Bar for Android
- Action Bar for Android
- Android Fragment & Action Bar
- android action bar progress
- Android Action Bar
- Android UI--Action Bar
- Android Action Bar
- 接口API定位
- ajax 传参json字符串
- Markdown示例
- java中计算机的执行机制002
- SVN导出项目(从虚拟机创建到项目运行六)
- android隐藏标题栏(Action Bar)
- One or more constraints have not been satisfied
- 【笔记】《WebGL编程指南》学习-第7章进入三维世界(1-视点和视线)
- 【上云须知】全面了解阿里云能为你做什么
- 八进制 输入一个整数,将其转换成八进制数输出
- ramdisk.img system.img userdata.img 分析
- 关于无人驾驶的过去、现在以及未来,看这篇文章就够了!
- vs2013+opencv2.4.13环境变量配置
- javascript 的 map/reduce