Android自定义属性时format选项可以取用的值
(1)属性定义:
- <declare-styleable name="名称">
- <attr format="reference" name="background" />
- </declare-styleable>
(2)属性使用:
- <ImageView
- android:layout_width="42dip"
- android:layout_height="42dip"
- android:background="@drawable/图片ID" />
2. color:颜色值。
(1)属性定义:
- <declare-styleable name="名称">
- <attr format="color" name="textColor" />
- </declare-styleable>
(2)属性使用:
- <TextView
- android:layout_width="42dip"
- android:layout_height="42dip"
- android:textColor="#00FF00" />
3. boolean:布尔值。
(1)属性定义:
- <declare-styleable name="名称">
- <attr format="boolean" name="focusable" />
- </declare-styleable>
(2)属性使用:
- <Button
- android:layout_width="42dip"
- android:layout_height="42dip"
- android:focusable="true" />
4. dimension:尺寸值。
(1)属性定义:
- <declare-styleable name="名称">
- <attr format="dimension" name="layout_width" />
- </declare-styleable>
(2)属性使用:
- <Button
- android:layout_width="42dip"
- android:layout_height="42dip" />
5. float:浮点值。
(1)属性定义:
- <declare-styleable name="AlphaAnimation">
- <attr format="float" name="fromAlpha" />
- <attr format="float" name="toAlpha" />
- </declare-styleable>
(2)属性使用:
- <alpha
- android:fromAlpha="1.0"
- android:toAlpha="0.7" />
6. integer:整型值。
(1)属性定义:
- <declare-styleable name="AnimatedRotateDrawable">
- <attr format="integer" name="frameDuration" />
- <attr format="integer" name="framesCount" />
- </declare-styleable>
(2)属性使用:
- <animated-rotate
- android:frameDuration="100"
- android:framesCount="12"
- />
7. string:字符串。
(1)属性定义:
- <declare-styleable name="MapView">
- <attr format="string" name="apiKey" />
- </declare-styleable>
(2)属性使用:
- <com.google.android.maps.MapView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:apiKey="0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g" />
8. fraction:百分数。
(1)属性定义:
- <declare-styleable name="RotateDrawable">
- <attr format="fraction" name="pivotX" />
- <attr format="fraction" name="pivotY" />
- </declare-styleable>
(2)属性使用:
- <rotate
- android:pivotX="200%"
- android:pivotY="300%"
- />
9. enum:枚举值。
(1)属性定义:
- <declare-styleable name="名称">
- <attr name="orientation">
- <enum name="horizontal" value="0" />
- <enum name="vertical" value="1" />
- </attr>
- </declare-styleable>
(2)属性使用:
- <LinearLayout
- android:orientation="vertical" >
- </LinearLayout>
10. flag:位或运算。
(1)属性定义:
- <declare-styleable name="名称">
- <attr name="windowSoftInputMode">
- <flag name="stateUnspecified" value="0" />
- <flag name="stateUnchanged" value="1" />
- <flag name="stateHidden" value="2" />
- <flag name="stateAlwaysHidden" value="3" />
- <flag name="stateVisible" value="4" />
- <flag name="stateAlwaysVisible" value="5" />
- <flag name="adjustUnspecified" value="0x00" />
- <flag name="adjustResize" value="0x10" />
- <flag name="adjustPan" value="0x20" />
- <flag name="adjustNothing" value="0x30" />
- </attr>
- </declare-styleable>
(2)属性使用:
- <activity
- android:windowSoftInputMode="stateUnspecified | stateUnchanged | stateHidden" >
- </activity>
注意:属性定义时可以指定多种类型值:
(1)属性定义:
- <declare-styleable name="名称">
- <attr format="reference|color" name="background" />
- </declare-styleable>
(2)属性使用:
- <ImageView
- android:layout_width="42dip"
- android:layout_height="42dip"
- android:background="@drawable/图片ID|#00FF00" />
Android自定义属性时format选项可以取用的值的更多相关文章
- (转)Android自定义属性时format选项( <attr format="reference" name="background" /> )
Android自定义属性时format选项可以取用的值 1. reference:参考某一资源ID. (1)属性定义: [html] view plaincopyprint? <declar ...
- Android自定义属性时TypedArray的使用方法
有时候android传统的页面布局不足以满足我们的需求,常常需要自己定义view,通常继承View,然后重写构造方法以及onDraw等函数,再 具体实现自己定义的复杂view.我们知道在给控件赋属性时 ...
- Android自定义属性,format详解
1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = &quo ...
- Android自定义属性
上一篇讲解了Android自定义View,这篇来讲解一下Android自定义属性的使用,让你get新技能.希望我的分享能帮助到大家. 做Android布局是件很享受的事,这得益于他良好的xml方式.使 ...
- Android-深入理解android自定义属性(AttributeSet,TypedArray)
属性 自定义属性,首先要定义出来属性,我们新建一个attrs.xml: <?xml version="1.0" encoding="utf-8"?> ...
- Android开发 ---xml构建选项菜单、上下文菜单(长按显示菜单)、发通知、发送下载通知
1.activity_main.xml 描述: 定义了一个TextView和三个按钮 <?xml version="1.0" encoding="utf-8&quo ...
- android.content.res.TypedArray-深入理解android自定义属性(AttributeSet,TypedArray)
属性 自定义属性,首先要定义出来属性,我们新建一个attrs.xml: <?xml version="1.0" encoding="utf-8"?> ...
- Android自定义属性简单使用说明
原创文章,转载请注明出处:http://www.cnblogs.com/baipengzhan/p/Android_attrs.html 本文从实用角度说明Android自定义属性的基本使用流程,清晰 ...
- 第一次使用Android Studio时你应该知道的一切配置(二):新建一个属于自己的工程并安装Genymotion模拟器
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
随机推荐
- 重大发现Android studio 如何简单快速修改package name
好多人都发现Android studio修改包名比较麻烦,只能一级一级的修改,今天偶尔发现了一个快捷方法. 废话不多说: 1 打开项目的AndroidManifest.xml文件 2 鼠标光笔定位到你 ...
- asp.net Hierarchical Data
Introduction A Hierarchical Data is a data that is organized in a tree-like structure and structure ...
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
操作环境 操作系统:Mac Os Lion 虚拟主机:VMware Fusion 虚拟系统:Centos 5.5+ 操作用户:Root 实现目的:搭建LNMP环境. 安装依赖库和开发环境 #依赖库和开 ...
- 第二十六篇、因为自定item(nav)而使系统右滑返回手势失效的解决方法
@interface ViewController () <uigesturerecognizerdelegate> @end@implementation ViewController ...
- [.Net MVC] 使用 log4net 日志框架
项目:后台管理平台 意义:项目开发中提出增加日志功能,对关键的操作.程序运行中的错误信息进行记录,这对程序部署后的调试有很大意义. 注:本文只是对网上搜集的信息进行了整合,以备今后查询. 关键字:.N ...
- 常用AWK命令
常用AWK命令 Awk is a programming language which allows easy manipulation of structured data and the gene ...
- 九度OJ 1351 数组中只出现一次的数字
题目地址:http://ac.jobdu.com/problem.php?pid=1351 题目描述: 一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字. 输 ...
- Yii 通过widget小物件生成添加表单
通过widget小物件创建添加商品的表单 视图里,表单以endWidget();?>结束 最终效果: 把表单提交过来的信息保存到数据库中去. 补充要点: 密码表单: <?php echo ...
- Python3 内建模块 hashlib、itertools、HTMLParser、urllib
Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢?摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定的数据串(通常用16进制 ...
- JQuery(一) 入门
JQuery是一个JS库,可以跨浏览器运行,若开发者面对jQuery编程,则可以在不同的浏览器自由切换. jQuery不再像JS一样面向DOM,而是面向jQuery对象. jQuery提供$()函数, ...