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.AppCompat
themes 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 ...
随机推荐
- 20140717 随笔 技术文章安家至CSDN
今天意外的看到了阳光小强的博客,接着在CSDN里看着各种博客,又有一种冲动,想在CSDN里安家.我是一个不安分的人,或者说是不能坚持的人,喜新厌旧属于我吧.看到新鲜的就要去试一下,但是能够坚持下来的却 ...
- 【html】【8】div布局[子div在父div居底]
从今天起 开始细话div布局 思路及要点: 父div的位置设置成相对的,即“position: relative;”. 而子div的位置设置成绝对的,并且下边缘设为0,即“position: ab ...
- ZOJ 1122 Clock(模拟)
Clock Time Limit: 2 Seconds Memory Limit: 65536 KB You are given a standard 12-hour clock with ...
- 九度OJ 1408 吃豆机器人 -- 动态规划
题目地址:http://ac.jobdu.com/problem.php?pid=1408 题目描述: 淘宝公司内部有许多新鲜的小玩具,例如淘宝智能机器人.小时候,大家都玩过那个吃豆子的游戏吧,这机器 ...
- 菜鸟的MySQL学习笔记(一)
本学习笔记是照搬慕课网<与MySQL的零距离接触>内容,特此感谢! 1-1 mysql的安装与配置 Windows环境下的MSI安装: 1.安装: 双击MSI文件->用户协议-> ...
- PHP - 5.4 Array dereferencing 数组值
在5.4之前我们直接获取数组的值得方法如下 <?php $str = 'a;b;c;d'; list($value) = explode(';',$str); echo $value; 结果为: ...
- JS 获取 路径参数 传入 参数名 截取 & 和 # 之前 字符
function getQueryStringByName(name) { var result = location.search.match(new RegExp("[\?\&] ...
- Tips of Python!
Tips of Python!(Python 2.7) (不定期更新中-) 1. raw_input() 和 input(): raw_input() 将输入原封不动的保存为一个字符串 输入 1 + ...
- 学习hash_map从而了解如何写stl里面的hash函数和equal或者compare函数
---恢复内容开始--- 看到同事用unordered_map了所以找个帖子学习学习 http://blog.sina.com.cn/s/blog_4c98b9600100audq.html (一)为 ...
- ASP.NET MVC Spring.NET NHibernate 整合
请注明转载地址:http://www.cnblogs.com/arhat 在整合这三个技术之前,首先得说明一下整合的步骤,俗话说汗要一口一口吃,事要一件一件做.同理这个三个技术也是.那么在整合之前,需 ...