Android setDisplayOptions 具体的使用说明
Android有几个地方使用位计算。实例Intent Flags,它们的定义View onMeasure(int widthMeasureSpec, int heightMeasureSpec),并且ActionBar setDisplayOptions ,以下就理解一下setDisplayOptions的使用方法。
先看下文档中对他的描写叙述:
public abstract void setDisplayOptions (int options)
Set display options. This changes all display option bits at once. To change a limited subset of display options, see setDisplayOptions(int,
.
int)
Parameters
options | A combination of the bits defined by the DISPLAY_ constants defined in ActionBar. |
---|
public abstract void setDisplayOptions (int options, int mask)
Set selected display options. Only the options specified by mask will be changed. To change all display option bits at once, see setDisplayOptions(int)
.
Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the DISPLAY_SHOW_HOME
option.
setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) will enable DISPLAY_SHOW_HOME
and
disable DISPLAY_USE_LOGO
.
Parameters
options | A combination of the bits defined by the DISPLAY_ constants defined in ActionBar. |
---|---|
mask | A bit mask declaring which display options should be changed. |
选择部分来显示设置,仅仅有当options在mask中被设置才干被显示。也就是设置为true。
那么问题来了。。。
究竟怎么用options 和mask尼?看以下内容
- ActionBar默认假设没有做不论什么设置,会显示出一个箭头(DISPLAY_HOME_AS_UP),一个logo(DISPLAY_SHOW_HOME),标题(DISPLAY_SHOW_TITLE)
- 一旦使用setDisplayOptions(int options)这种方法,全部的设置项都变成了false,options使用或运算加入设置。加入一个就设置一个为true-显示,比方setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM),就是设置显示返回箭头和customView
- setDisplayOptions(int options,int mask)方法,即在当前默认的ActionBar设置项内。选择几个来设置。这种场景可能是Activity内部的Fragment。须要给Fragment设置ActionBar的几个确定选项,比方
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);
options为 ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM
知道了原理我们就能够这样用,比方我们仅仅要显示a,b,c三个选项,
那么就使用getSupportActionBar().setDisplayOptions(
a|b|c );
假设我们在特定的条件下,比方fragment中,须要仅仅对b,c,d这三个选项进行设置,把b。c设置为显示。d设置为隐藏,那么就能够使用getSupportActionBar().setDisplayOptions(b|c
, b|c|d );
用了这种方法就不须要一个一个的设置setDisplayShowXXX()了
了解很多其它能够去:http://blog.csdn.net/zzp16/article/details/7956768
版权声明:本文博主原创文章。博客,未经同意不得转载。
Android setDisplayOptions 具体的使用说明的更多相关文章
- Gprinter Android SDK V1.0 使用说明
佳博打印机代理商淘宝店https://shop107172033.taobao.com/index.htm?spm=2013.1.w5002-9520741823.2.Sqz8Pf 在此店购买的打印机 ...
- Gprinter Android SDK V2.0 使用说明
佳博特约经销商,此店购买的打印机问题优先解决哟 https://shop107172033.taobao.com/index.htm?spm=2013.1.w5002-9520741823.2.V1p ...
- 【Android】Android import和export使用说明 及 export报错:jarlist.cache: Resource is out of sync with the file syst解决
在Android开发export项目时发现有时会报错,内容如下: Problems were encountered during export: Error exporting PalmIdent ...
- Android TableLayout中的使用说明
TableLayout特点: 1)TableLayout和我们平时在网页上见到的Table有所不同,TableLayout没有边框的 2)它是由多个TableRow对象组成,每个TableRow可以有 ...
- Android 7.0 FileProvider 使用说明
FileProvider FileProvider 这个组件在Android 22.0.0 (也就是 Android 5.0 ) 版本下加入进Android系统,该组件是ContentProvider ...
- Android LitePal介绍与使用说明
LitePal for Android LitePal是一个Android开源库,它使开发者使用SQLite数据库变得非常容易. 你可以不用写一句SQL语句就可以完成大部分数据库操作,包括创建表,更新 ...
- Android.mk文件官方使用说明
本页介绍了 ndk-build 所使用的 Android.mk 编译文件的语法. 概览 Android.mk 文件位于项目 jni/ 目录的子目录中,用于向编译系统描述源文件和共享库.它实际上是编译系 ...
- Gprinter Android SDK V2.1 使用说明
下载:http://download.csdn.net/download/abc564643122/8872249
- Android进程保活
Android进程回收机制 Low Memory Killer原理 微信团队原创分享:Android版微信后台保活实战分享(网络保活篇) 微信团队原创分享:Android版微信后台保活实战分享(进程保 ...
随机推荐
- cocos2d-x 旅程開始--(实现瓦片地图中的碰撞检測)
转眼隔了一天了,昨天搞了整整一下午加一晚上,楞是没搞定小坦克跟砖头的碰撞检測,带着个问题睡觉甚是难受啊!还好今天弄成功了.只是感觉程序不怎么稳定啊.并且发现自己写的东西让我重写一遍的话我肯定写不出来. ...
- FragmentCustomAnimation实现Fragment的界面切换
1.知识点:FragmentCustomAnimation 2.演示样例:来自于官网演示样例的简化,这样更方便于学习该知识点. 本演示样例的源代码下载地址为:http://download.csdn. ...
- ThreadSafeClientConnManager的20个例子
Java Code Examples for org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager The following are ...
- uva 11722 - Joining with Friend(概率)
题目连接:uva 11722 - Joining with Friend 题目大意:你和朋友乘火车,而且都会路过A市.给定两人可能到达A市的时段,火车会停w.问说两人能够见面的概率. 解题思路:y = ...
- gwt CellTable中的控件按Tab键切换
默认是 cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); 如果要Tab,则设置为DISABLED; 并将其t ...
- Linux查看进程线程个数
1.根据进程号进行查询: # pstree -p 进程号 # top -Hp 进程号 2.根据进程名字进行查询: # pstree -p `ps -e | grep server | awk '{pr ...
- srm 533
250 Description 给你一串数字序列,每次删掉第ii个数.获得权值w[i−1]×w[i+1]w[i-1]\times w[i+1],求最后剩下第一个和最后一个数获得的最大权值和 Solut ...
- Shine we together: A innovative dating site using 2012 Nobel Laureate Roth's algorithm
Abstract Our dating site introduced scoring and its related functionalities innovatively, conforming ...
- 从零開始学android<数据存储(1)SharedPreferences属性文件.三十五.>
在android中有五种保存数据的方法.各自是: Shared Preferences Store private primitive data in key-value pairs. 相应属性的键值 ...
- 深入了解回调函数Java
打回来.我第一次看到Java编程思想,后来Observer模式也适用于一个回调函数的想法.但是,一直没有重视,在处于劣势的最终面试,越来越明白为什么那么多人说Java编程思想,这本书应该是一遍又一遍, ...