1. reference:参考某一资源ID。

(1)属性定义:

  1. <declare-styleable name="名称">
  2. <attr format="reference" name="background" />
  3. </declare-styleable>

(2)属性使用:

  1. <ImageView
  2. android:layout_width="42dip"
  3. android:layout_height="42dip"
  4. android:background="@drawable/图片ID" />

2. color:颜色值。

(1)属性定义:

 
  1. <declare-styleable name="名称">
  2. <attr format="color" name="textColor" />
  3. </declare-styleable>

(2)属性使用:

 
  1. <TextView
  2. android:layout_width="42dip"
  3. android:layout_height="42dip"
  4. android:textColor="#00FF00" />

3. boolean:布尔值。

(1)属性定义:

 
  1. <declare-styleable name="名称">
  2. <attr format="boolean" name="focusable" />
  3. </declare-styleable>

(2)属性使用:

 
  1. <Button
  2. android:layout_width="42dip"
  3. android:layout_height="42dip"
  4. android:focusable="true" />

4. dimension:尺寸值。

(1)属性定义:

 
  1. <declare-styleable name="名称">
  2. <attr format="dimension" name="layout_width" />
  3. </declare-styleable>

(2)属性使用:

 
  1. <Button
  2. android:layout_width="42dip"
  3. android:layout_height="42dip" />

5. float:浮点值。

(1)属性定义:

 
  1. <declare-styleable name="AlphaAnimation">
  2. <attr format="float" name="fromAlpha" />
  3. <attr format="float" name="toAlpha" />
  4. </declare-styleable>

(2)属性使用:

 
  1. <alpha
  2. android:fromAlpha="1.0"
  3. android:toAlpha="0.7" />

6. integer:整型值。

(1)属性定义:

 
  1. <declare-styleable name="AnimatedRotateDrawable">
  2. <attr format="integer" name="frameDuration" />
  3. <attr format="integer" name="framesCount" />
  4. </declare-styleable>

(2)属性使用:

 
  1. <animated-rotate
  2. android:frameDuration="100"
  3. android:framesCount="12"
  4. />

7. string:字符串。

(1)属性定义:

 
  1. <declare-styleable name="MapView">
  2. <attr format="string" name="apiKey" />
  3. </declare-styleable>

(2)属性使用:

 
  1. <com.google.android.maps.MapView
  2. android:layout_width="fill_parent"
  3. android:layout_height="fill_parent"
  4. android:apiKey="0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g" />

8. fraction:百分数。

(1)属性定义:


 
  1. <declare-styleable name="RotateDrawable">
  2. <attr format="fraction" name="pivotX" />
  3. <attr format="fraction" name="pivotY" />
  4. </declare-styleable>

(2)属性使用:

 
  1. <rotate
  2. android:pivotX="200%"
  3. android:pivotY="300%"
  4. />

9. enum:枚举值。

(1)属性定义:

 
  1. <declare-styleable name="名称">
  2. <attr name="orientation">
  3. <enum name="horizontal" value="0" />
  4. <enum name="vertical" value="1" />
  5. </attr>
  6. </declare-styleable>

(2)属性使用:

  1. <LinearLayout
  2. android:orientation="vertical" >
  3. </LinearLayout>

10. flag:位或运算。

(1)属性定义:

 
  1. <declare-styleable name="名称">
  2. <attr name="windowSoftInputMode">
  3. <flag name="stateUnspecified" value="0" />
  4. <flag name="stateUnchanged" value="1" />
  5. <flag name="stateHidden" value="2" />
  6. <flag name="stateAlwaysHidden" value="3" />
  7. <flag name="stateVisible" value="4" />
  8. <flag name="stateAlwaysVisible" value="5" />
  9. <flag name="adjustUnspecified" value="0x00" />
  10. <flag name="adjustResize" value="0x10" />
  11. <flag name="adjustPan" value="0x20" />
  12. <flag name="adjustNothing" value="0x30" />
  13. </attr>
  14. </declare-styleable>

(2)属性使用:

 
  1. <activity
  2. android:windowSoftInputMode="stateUnspecified | stateUnchanged | stateHidden" >
  3. </activity>

注意:属性定义时可以指定多种类型值:

(1)属性定义:

 
  1. <declare-styleable name="名称">
  2. <attr format="reference|color" name="background" />
  3. </declare-styleable>

(2)属性使用:

 
  1. <ImageView
  2. android:layout_width="42dip"
  3. android:layout_height="42dip"
  4. android:background="@drawable/图片ID|#00FF00" />
 

Android自定义属性时format选项可以取用的值的更多相关文章

  1. (转)Android自定义属性时format选项( <attr format="reference" name="background" /> )

    Android自定义属性时format选项可以取用的值   1. reference:参考某一资源ID. (1)属性定义: [html] view plaincopyprint? <declar ...

  2. Android自定义属性时TypedArray的使用方法

    有时候android传统的页面布局不足以满足我们的需求,常常需要自己定义view,通常继承View,然后重写构造方法以及onDraw等函数,再 具体实现自己定义的复杂view.我们知道在给控件赋属性时 ...

  3. Android自定义属性,format详解

    1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = &quo ...

  4. Android自定义属性

    上一篇讲解了Android自定义View,这篇来讲解一下Android自定义属性的使用,让你get新技能.希望我的分享能帮助到大家. 做Android布局是件很享受的事,这得益于他良好的xml方式.使 ...

  5. Android-深入理解android自定义属性(AttributeSet,TypedArray)

    属性 自定义属性,首先要定义出来属性,我们新建一个attrs.xml: <?xml version="1.0" encoding="utf-8"?> ...

  6. Android开发 ---xml构建选项菜单、上下文菜单(长按显示菜单)、发通知、发送下载通知

    1.activity_main.xml 描述: 定义了一个TextView和三个按钮 <?xml version="1.0" encoding="utf-8&quo ...

  7. android.content.res.TypedArray-深入理解android自定义属性(AttributeSet,TypedArray)

    属性 自定义属性,首先要定义出来属性,我们新建一个attrs.xml: <?xml version="1.0" encoding="utf-8"?> ...

  8. Android自定义属性简单使用说明

    原创文章,转载请注明出处:http://www.cnblogs.com/baipengzhan/p/Android_attrs.html 本文从实用角度说明Android自定义属性的基本使用流程,清晰 ...

  9. 第一次使用Android Studio时你应该知道的一切配置(二):新建一个属于自己的工程并安装Genymotion模拟器

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...

随机推荐

  1. 重大发现Android studio 如何简单快速修改package name

    好多人都发现Android studio修改包名比较麻烦,只能一级一级的修改,今天偶尔发现了一个快捷方法. 废话不多说: 1 打开项目的AndroidManifest.xml文件 2 鼠标光笔定位到你 ...

  2. asp.net Hierarchical Data

    Introduction A Hierarchical Data is a data that is organized in a tree-like structure and structure ...

  3. Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17

    操作环境 操作系统:Mac Os Lion 虚拟主机:VMware Fusion 虚拟系统:Centos 5.5+ 操作用户:Root 实现目的:搭建LNMP环境. 安装依赖库和开发环境 #依赖库和开 ...

  4. 第二十六篇、因为自定item(nav)而使系统右滑返回手势失效的解决方法

    @interface ViewController () <uigesturerecognizerdelegate> @end@implementation ViewController ...

  5. [.Net MVC] 使用 log4net 日志框架

    项目:后台管理平台 意义:项目开发中提出增加日志功能,对关键的操作.程序运行中的错误信息进行记录,这对程序部署后的调试有很大意义. 注:本文只是对网上搜集的信息进行了整合,以备今后查询. 关键字:.N ...

  6. 常用AWK命令

    常用AWK命令 Awk is a programming language which allows easy manipulation of structured data and the gene ...

  7. 九度OJ 1351 数组中只出现一次的数字

    题目地址:http://ac.jobdu.com/problem.php?pid=1351 题目描述: 一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字. 输 ...

  8. Yii 通过widget小物件生成添加表单

    通过widget小物件创建添加商品的表单 视图里,表单以endWidget();?>结束 最终效果: 把表单提交过来的信息保存到数据库中去. 补充要点: 密码表单: <?php echo ...

  9. Python3 内建模块 hashlib、itertools、HTMLParser、urllib

    Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢?摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定的数据串(通常用16进制 ...

  10. JQuery(一) 入门

    JQuery是一个JS库,可以跨浏览器运行,若开发者面对jQuery编程,则可以在不同的浏览器自由切换. jQuery不再像JS一样面向DOM,而是面向jQuery对象. jQuery提供$()函数, ...