1. Reference: Refer to a resource ID.
(1) Attribute definition:
<declare-styleable name = "Names" >
<attr name = "Background" format = "Reference"/>
</declare-styleable>
(2) attribute use:
<imageview
Android:layout_width = "42dip"
Android:layout_height = "42dip"
Android:background = "@drawable/Picture ID"
/>
2. Color: Colour value.
(1) Attribute definition:
<declare-styleable name = "Names" >
<attr name = "TextColor" format = "Color"/>
</declare-styleable>
(2) attribute use:
<textview
Android:layout_width = "42dip"
Android:layout_height = "42dip"
Android:textcolor = "#00FF00"
/>
3. Boolean: Boolean value.
(1) Attribute definition:
<declare-styleable name = "Names" >
<attr name = "focusable" format = "Boolean"/>
</declare-styleable>
(2) attribute use:
<button
Android:layout_width = "42dip"
Android:layout_height = "42dip"
Android:focusable = "true"
/>
4. Dimension: Dimension value.
(1) Attribute definition:
<declare-styleable name = "Names" >
<attr name = "layout_width" format = "Dimension"/>
</declare-styleable>
(2) attribute use:
<button
Android:layout_width = "42dip"
Android:layout_height = "42dip"
/>
5. Float: floating-point value.
(1) Attribute definition:
<declare-styleable name = "Alphaanimation" >
<attr name = "Fromalpha" format = "float"/>
<attr name = "Toalpha" format = "float"/>
</declare-styleable>
(2) attribute use:
<alpha
Android:fromalpha = "1.0"
Android:toalpha = "0.7"
/>
6. Integer: Integer value.
(1) Attribute definition:
<declare-styleable name = "Animatedrotatedrawable" >
<attr name = "visible"/>
<attr name = "frameduration" format= "integer"/>
<attr name = " Framescount "format=" integer "/>
<attr name = "Pivotx"/>
<attr name = "Pivoty"/>
<attr name = " Drawable "/>
</declare-styleable>
(2) attribute use:
<animated-rotate
xmlns:android = "Http://schemas.android.com/apk/res/android" &NBSP;&NBSP;
android:drawable = "@drawable/Picture ID "&NBSP;&NBSP;
Android:pivotx = "50%" &NBSP;&NBSP;
Android:pivoty = "50%" &NBSP;&NBSP;
android:framescount = "&NBSP;&NBSP";
android:frameduration = "+"
/>
7. String: Strings.
(1) Attribute definition:
<declare-styleable name = "Mapview" >
<attr name = "ApiKey" format = "string"/>
</declare-styleable>
(2) attribute use:
<com.google.android.maps.mapview
Android:layout_width = "Fill_parent"
Android:layout_height = "Fill_parent"
Android:apikey = "0jokq80od1jl9c6haja99ugxcris2cgjko_bc_g"
/>
8. Fraction: percentage.
(1) Attribute definition:
<declare-styleable name= "Rotatedrawable" >
<attr name = "visible"/>
<attr name = "fromdegrees" format = "float"/>
<attr name = "todegrees" format = "float"/>
<attr name = "Pivotx" format = "fraction"/>
<attr name = "Pivoty" format = "fraction"/>
<attr name = "Drawable"/>
</declare-styleable>
(2) attribute use:
<rotate
xmlns:android = "Http://schemas.android.com/apk/res/android"
Android:interpolator = "@anim/animation ID"
Android:fromdegrees = "0"
Android:todegrees = "360"
Android:pivotx = "200%"
Android:pivoty = "300%"
android:duration = "5000"
Android:repeatmode = "Restart"
Android:repeatcount = "Infinite"
/>
9. Enum: enumeration value.
(1) Attribute definition:
<declare-styleable name= "Name" >
<attr name= "Orientation" >
<enum name= "Horizontal" value= "0"/>
<enum name= "Vertical" value= "1"/>
</attr>
</declare-styleable>
(2) attribute use:
<linearlayout
xmlns:android = "Http://schemas.android.com/apk/res/android"
Android:orientation = "vertical"
Android:layout_width = "Fill_parent"
Android:layout_height = "Fill_parent"
>
</LinearLayout>
Flag: Bit or operation.
(1) Attribute definition:
<declare-styleable name= "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) attribute use:
<activity
Android:name = ". Styleandthemeactivity "
Android:label = "@string/app_name"
Android:windowsoftinputmode = "Stateunspecified | stateunchanged | Statehidden ">
<intent-filter>
<action android:name = "Android.intent.action.MAIN"/>
<category android:name = "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Attention:
Multiple types of values can be specified when the property is defined.
(1) Attribute definition:
<declare-styleable name = "Names" >
<attr name = "Background" format = "Reference|color"/>
</declare-styleable>
(2) attribute use:
<imageview
Android:layout_width = "42dip"
Android:layout_height = "42dip"
Android:background = "@drawable/Picture id| #00FF00"
/>
Reference: http://blog.csdn.net/sunny2come/article/details/6996943
Android Custom Properties format type