1. 程式人生 > >attrs.xml檔案中屬性型別format值的格式 .

attrs.xml檔案中屬性型別format值的格式 .

[java] view plaincopyprint?
  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 plaincopyprint?
  1. <attrname
    ="orientation">
  2. <enumname="horizontal"value="0"/>
  3. <enumname="vertical"value="1"/>
  4. < /attr>
< attr name="orientation">
  < enum name="horizontal" value="0" />
  < enum name="vertical" value="1" />
< /attr>
XML檔案中使用:
[html] view plaincopyprint?
  1. android:orientation = 
    "vertical"
android:orientation = "vertical"

標誌位、位或運算,格式如下:
[html] view plaincopyprint?
  1. <attrname="windowSoftInputMode">
  2. <flagname = "stateUnspecified"value = "0"/>
  3. <flagname = "stateUnchanged"value = "1"/>
  4. <flagname = "stateHidden"value = "2"/>
  5. <flagname = "stateAlwaysHidden"value
     = "3"/>
  6. <flagname = "stateVisible"value = "4"/>
  7. <flagname = "stateAlwaysVisible"value = "5"/>
  8. <flagname = "adjustUnspecified"value = "0x00"/>
  9. <flagname = "adjustResize"value = "0x10"/>
  10. <flagname = "adjustPan"value = "0x20"/>
  11. <flagname = "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 plaincopyprint?
  1. android:windowSoftInputMode = "stateUnspecified | stateUnchanged | stateHidden">
android:windowSoftInputMode = "stateUnspecified | stateUnchanged | stateHidden">

屬性定義可以指定多種型別:
[html] view plaincopyprint?
  1. <attrname = "background"format = "reference|color"/>
< attr name = "background" format = "reference|color" />
XML檔案中使用:
[html] view plaincopyprint?
  1. android:background = "@drawable/圖片ID|#00FF00"