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. 日志记录类LogHelper

    开源日志log4net使用起来很方便,但是项目中不让用,所以自己重写了一个类,用来记录日志,比较简单. 1.首先是可以把日志分成多个类型,分别记录到不同的文件中 /// <summary> ...

  2. (八)Hibernate 映射关系

    所有项目导入对应的hibernate的jar包.mysql的jar包和添加每次都需要用到的HibernateUtil.java 第一节:Hibernate 一对一映射关系实现 1,按照主键映射: 2, ...

  3. 01线性表顺序存储_List--(线性表)

    #include "stdio.h" #include "stdlib.h" #include "io.h" #include " ...

  4. SQL日期操作及只获取日期的方法

    datepart()函数的使用                          * datepart()函数可以方便的取到时期中的各个部分*如日期:2006-07--02 18:15:36.513* ...

  5. HDU 1069 Monkey and Banana(动态规划)

    Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...

  6. LNK1169 和 LNK2005

    错误重现: 1> vs2010创建 C++ win32 project, Application type: DLL. 2>为了在工程中使用 CString, 在 stdafx.h 中 I ...

  7. Trie的C++实现及HDU1251,hdu1671

    #include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...

  8. PHOTOSHOP 半透明方格

    1.新建60*60的透明文档,在左方和上方用直线工具画白边,存储为图案(编辑/定义图案) 2.新建图层,用油漆桶填充图案 3. 选择若干小方格,填充白色后设置不透明度50%

  9. linux 源码安装软件原理

    make 与 configure 在使用类似 gcc 的编译器来进行编译的过程并不简单,因为一套软件并不会仅有一支程序,而是有一堆程序码文件.所以除了每个主程序与副程序均需要写上一笔编译过程的命令外, ...

  10. SQL获取数据库中表的列名和列类型

    select column_name as [字段名],data_type as [数据类型] from information_schema.columns where table_name='表名 ...