attrs.xml文件中属性类型format值的格式 .

android reference integer string float
[java] view plain copy print ?
  1. "reference" //引用   
  2. "color" //颜色   
  3. "boolean" //布尔值   
  4. "dimension" //尺寸值   
  5. "float" //浮点值   
  6. "integer" //整型值   
  7. "string" //字符串   
  8. "fraction" //百分数,比如200%  
"reference" //引用
"color" //颜色
"boolean" //布尔值
"dimension" //尺寸值
"float" //浮点值
"integer" //整型值
"string" //字符串
"fraction" //百分数,比如200%

枚举型的格式:

[html] view plain copy print ?
  1. < attr name="orientation">  
  2.   < enum name="horizontal" value="0" />  
  3.   < enum name="vertical" value="1" />  
  4. < /attr>  
< attr name="orientation">
  < enum name="horizontal" value="0" />
  < enum name="vertical" value="1" />
< /attr>
XML文件中使用:
[html] view plain copy print ?
  1. android:orientation = "vertical"  
android:orientation = "vertical"

标志位、位或运算,格式如下:
[html] view plain copy print ?
  1. < attr name="windowSoftInputMode">  
  2.   < flag name = "stateUnspecified" value = "0" />  
  3.   < flag name = "stateUnchanged" value = "1" />  
  4.   < flag name = "stateHidden" value = "2" />  
  5.   < flag name = "stateAlwaysHidden" value = "3" />  
  6.   < flag name = "stateVisible" value = "4" />  
  7.   < flag name = "stateAlwaysVisible" value = "5" />  
  8.   < flag name = "adjustUnspecified" value = "0x00" />  
  9.   < flag name = "adjustResize" value = "0x10" />  
  10.   < flag name = "adjustPan" value = "0x20" />  
  11.   < flag name = "adjustNothing" value = "0x30" />  
  12. < /attr>  
< 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>
XML文件中使用:
[html] view plain copy print ?
  1. android:windowSoftInputMode = "stateUnspecified | stateUnchanged | stateHidden">  
android:windowSoftInputMode = "stateUnspecified | stateUnchanged | stateHidden">

属性定义可以指定多种类型:
[html] view plain copy print ?
  1. < attr name = "background" format = "reference|color" />  
< attr name = "background" format = "reference|color" />
XML文件中使用:
[html] view plain copy print ?
  1. android:background = "@drawable/图片ID|#00FF00"  

你可能感兴趣的:(attrs.xml文件中属性类型format值的格式 .)