您的位置:首页 > 其它

自定义控件一:自定义属性讲解

2015-05-13 17:19 309 查看
在自定义控件中常用属性值有:color、boolean、dimension、float、integer、string、fraction、enum、flag。

1. reference:

属性申明:

<declare-styleable name = "名称">

</declare-styleable>

2.具体属性值定义: 

①color:

 <attr name = "textColor" format = "color" />

②boolean:

<attr name = "focusable" format = "boolean" />

③dimension:尺寸值:

 <attr name = "layout_width" format = "dimension" />

④ float:浮点值:

<attr name = "toAlpha"
format = "float" />

 ⑤integer:整型值。

<attr name = "framesCount"
format="integer" />

⑥ string:字符串。

 <attr name = "apiKey"
format = "string" />

⑦ fraction:百分数。

<attr name = "pivotX"
format = "fraction" />

⑧ enum:枚举值。

<attr name="orientation">

     <enum name="horizontal" value="0" />

     <enum name="vertical" value="1" />

</attr>            

⑨ flag:位或运算。

<flag name = "stateUnspecified" value = "0" />

                        
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  自定义属性
相关文章推荐