ActionBar官方教程(2)选主题让应用支或不支持ActionBar及支持ActionBar的应用如何隐藏和显示
Adding the Action Bar
As mentioned above, this guide focuses on how to use the ActionBar APIs in the support library. So before you can add the action bar, you must set up your project with the appcompat v7 support library by following the instructions in the Support Library Setup.
Once your project is set up with the support library, here's how to add the action bar:
- Create your activity by extending
ActionBarActivity. - Use (or extend) one of the
Theme.AppCompatthemes for your activity. For example:<activity android:theme="@style/Theme.AppCompat.Light" ... >
Now your activity includes the action bar when running on Android 2.1 (API level 7) or higher.
On API level 11 or higher
The action bar is included in all activities that use the Theme.Holo theme (or one of its descendants), which is the default theme when either the targetSdkVersion or minSdkVersion attribute is set to "11" or higher. If you don't want the action bar for an activity, set the activity theme to Theme.Holo.NoActionBar.
主题Theme.Holo.NoActionBar不支持ActionBar,Theme.Holo 支持ActionBar
Removing the action bar
You can hide the action bar at runtime by calling hide(). For example:
ActionBar actionBar = getSupportActionBar(); actionBar.hide();
On API level 11 or higher
Get the ActionBar with the getActionBar() method.
When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().
隐藏:ActionBar.hidden(),显示:ActionBar.show()
Beware that hiding and removing the action bar causes your activity to re-layout in order to account for the space consumed by the action bar. If your activity often hides and shows the action bar, you might want to enable overlay mode. Overlay mode draws the action bar in front of your activity layout, obscuring the top portion. This way, your layout remains fixed when the action bar hides and re-appears. To enable overlay mode, create a custom theme for your activity and set windowActionBarOverlay to true. For more information, see the section below about Styling the Action Bar.
注意: 如果经常隐藏,显示,那么要用overlay mode
ActionBar官方教程(2)选主题让应用支或不支持ActionBar及支持ActionBar的应用如何隐藏和显示的更多相关文章
- ActionBar官方教程(11)自定义ActionBar的样式(含重要的样式属性表及练习示例)
Styling the Action Bar If you want to implement a visual design that represents your app's brand, th ...
- ActionBar官方教程(10)ActionBar的下拉列表模式
Adding Drop-down Navigation As another mode of navigation (or filtering) for your activity, the acti ...
- ActionBar官方教程(9)ActionBar的顶部tab模式(注意,已经被弃用)
This interface is deprecated.Action bar navigation modes are deprecated and not supported by inline ...
- ActionBar官方教程(6)把图标变成一个返回到上级的按钮,同一个app间,不同app间,不同fragment间
Navigating Up with the App Icon Enabling the app icon as an Up button allows the user to navigate yo ...
- ActionBar官方教程(5)ActionBar的分裂模式(底部tab样式),隐藏标题,隐藏图标
Using split action bar Split action bar provides a separate bar at the bottom of the screen to displ ...
- ActionBar官方教程(3)更改标题处的图片
Using a logo instead of an icon By default, the system uses your application icon in the action bar, ...
- ActionBar官方教程(1)简介及各区域介绍
Action Bar The action bar is a window feature that identifies the user location, and provides user a ...
- ActionBar官方教程(8)ShareActionProvider与自定义操作项提供器
Adding an Action Provider Similar to an action view, an action provider replaces an action button wi ...
- ActionBar官方教程(7)自定义操作项的view,如何得到它及处理它的事件
Adding an Action View An action view is a widget that appears in the action bar as a substitute for ...
随机推荐
- 12天学好C语言——记录我的C语言学习之路(Day 11)
12天学好C语言--记录我的C语言学习之路 Day 11: 因为指针部分比较的难,所以我们花费的时间也是最长的,希望大家耐的住性子,多多理解,多多打代码.好了,废话不多说,来看第11天的学习. //编 ...
- Python(Django) 连接MySQL(Mac环境)
看django的文档,详细的一塌糊涂,这对文档来时倒是好事,可是数据库连接你别一带而过啊.感觉什么都想说又啥都没说明白,最有用的一句就是推荐mysqlclient.展开一个Django项目首先就是成功 ...
- java_object的具体使用--上帝
就我们所知道的,java中有子类和父类,子类由于继承父类而形成,那么父类还有没有父类呢?答案是有了,父类的父类就是object类,一切父类都继承了它,那么根据继承的属性,每一个子类都有一个object ...
- HTML Music Entities/音乐符号
HTML Music Entities Musical symbols Description Character(click) HTML-Entity Code-Decimal Code-Hex Q ...
- 九度OJ 1497 面积最大的全1子矩阵 -- 动态规划
题目地址:http://ac.jobdu.com/problem.php?pid=1497 题目描述: 在一个M * N的矩阵中,所有的元素只有0和1,从这个矩阵中找出一个面积最大的全1子矩阵,所谓最 ...
- OpenJudge 2756 二叉树
1.链接地址: http://bailian.openjudge.cn/practice/2756/ 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 如 上图所示,由正整数1 ...
- 无线WEP入侵注意事项
1.工具bt3/bt4+spoonwep2(dep安装包)+U盘/VMwmare+无线网卡(可以笔记本内置)+UltraISO+unetbootin-windows-latest.exe+2.内置网卡 ...
- tomcat错误信息解决方案 严重:StandardServer.await:
看到这个报错我的第一反应就是端口被占用,用netstat -ant命令查看发现8080端口没有被占用,也可以看到 tomcat的进程已经存在,但是不能对外提供服务. 1.独立运行的tomcat.exe ...
- win7 蛋疼的时间格式转化
win7系统 获得系统时间为 2015年1月1日 星期5 10:10 数据库中时间格式 是不认识的 转化为 DateTime.Now.ToString("yyyy-MM-dd HH:mm:s ...
- Universal-Image-Loader(UIL)使用方法&流程图&源码分析 ----- 未完
GitHub源码: Android-Universal-Image-Loader Features Multithread image loading (async or sync) 多线程加载(同步 ...