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 ...
随机推荐
- java反射案例讲解
本篇文章依旧采用小例子来说明,因为我始终觉的,案例驱动是最好的,要不然只看理论的话,看了也不懂,不过建议大家在看完文章之后,在回过头去看看理论,会有更好的理解. 下面开始正文. [案例1]通过一个对象 ...
- JDBC向oracle插入数据
public static void main(String[] args) throws SQLException { 2 3 4 String driver="oracle.jdbc.d ...
- IOS-UI-UIDynamic(二)
UIPushBehavior :推动效果 UIAttachmentBehavior:附着效果 UISnapBehavior:迅速移动效果 一.重要的属性 UIPushBehavior :推动效果 ty ...
- [MAXscript Tool]TimeSlider v1.3
一个简单的小工具,方便在MAX里面快速的修改帧速率,像maya一样.具体看视频演示.
- 再也不要看到Eclipse万恶的arg0,arg1提示
不知道大家跟我是否一下,遇到arg的提示. @Override public void onDateChanged(DatePicker arg0, int arg1, int arg2, int a ...
- 11_Servlet生命周期
[生命周期] 以前:之前的java程序,我们的Java类自己去new对象,自已实例化对象去调用. 现在:Servlet程序,Servlet的生命周期由TomCat服务器控制的. 我们要研究Servle ...
- QT宏 Q_OBJECT,explicit, QHostAddress, quint, emit
QT相關 一. 參考: 1.宏Q_OBJECT 二. explicit struct constrcution 三. QHostAddress Detailed Description: The QH ...
- CSU-ACM2016暑假集训训练2-DFS(C - Network Saboteur)
C - Network Saboteur Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- CAF(C++ actor framework)使用随笔(send sync_send)(二)
a). 发完就忘, 就像上面anon_send 以及send #include <iostream> #include "caf/all.hpp" #include & ...
- VPN client on linux debian
Install the pptp-linux and pptp-linux-client: sudo apt-get install pptp-linux pptp-linux-client Crea ...