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 ...
随机推荐
- 日志记录类LogHelper
开源日志log4net使用起来很方便,但是项目中不让用,所以自己重写了一个类,用来记录日志,比较简单. 1.首先是可以把日志分成多个类型,分别记录到不同的文件中 /// <summary> ...
- (八)Hibernate 映射关系
所有项目导入对应的hibernate的jar包.mysql的jar包和添加每次都需要用到的HibernateUtil.java 第一节:Hibernate 一对一映射关系实现 1,按照主键映射: 2, ...
- 01线性表顺序存储_List--(线性表)
#include "stdio.h" #include "stdlib.h" #include "io.h" #include " ...
- SQL日期操作及只获取日期的方法
datepart()函数的使用 * datepart()函数可以方便的取到时期中的各个部分*如日期:2006-07--02 18:15:36.513* ...
- HDU 1069 Monkey and Banana(动态规划)
Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...
- LNK1169 和 LNK2005
错误重现: 1> vs2010创建 C++ win32 project, Application type: DLL. 2>为了在工程中使用 CString, 在 stdafx.h 中 I ...
- Trie的C++实现及HDU1251,hdu1671
#include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...
- PHOTOSHOP 半透明方格
1.新建60*60的透明文档,在左方和上方用直线工具画白边,存储为图案(编辑/定义图案) 2.新建图层,用油漆桶填充图案 3. 选择若干小方格,填充白色后设置不透明度50%
- linux 源码安装软件原理
make 与 configure 在使用类似 gcc 的编译器来进行编译的过程并不简单,因为一套软件并不会仅有一支程序,而是有一堆程序码文件.所以除了每个主程序与副程序均需要写上一笔编译过程的命令外, ...
- SQL获取数据库中表的列名和列类型
select column_name as [字段名],data_type as [数据类型] from information_schema.columns where table_name='表名 ...