Androidカスタムコントロールの第一話:atr format取得タイプ

17943 ワード

1.reference:あるリソースIDを参照してください.
(1)属性定義:
<declare-styleable name = "  ">
    "background" format = "reference" />
declare-styleable>
  • 1
  • ,
  • (2)属性の使用:
    "42dip"
        android:layout_height = "42dip"
        android:background = "@drawable/  ID"/>  
  • 1
  • ,
  • 4
  • 2.カラー値.
    (1)属性定義:
    <declare-styleable name = "  ">
        "textColor" format = "color" />
    declare-styleable>
  • 1
  • ,
  • (2)属性の使用:
    "42dip"
        android:layout_height = "42dip"
        android:textColor = "#00FF00"/>
  • 1
  • ,
  • 4
  • 3.ブーメラン:ブール値.
    (1)属性定義:
    <declare-styleable name = "  ">
        "focusable" format = "boolean" />
    declare-styleable>
  • 1
  • ,
  • (2)属性の使用:
    <Button
        android:layout_width = "42dip"
        android:layout_height = "42dip"
        android:focusable = "true"/>
  • 1
  • ,
  • 4
  • 4.ディメンション:サイズ値.
    (1)属性定義:
    <declare-styleable name = "  ">
        "layout_width" format = "dimension" />
    declare-styleable>
  • 1
  • ,
  • (2)属性の使用:
    <Button
        android:layout_width = "42dip"
        android:layout_height = "42dip"/>
  • 1
  • ,
  • 5.float:浮動小数点値.
    (1)属性定義:
    name = "AlphaAnimation">
        name = "fromAlpha" format = "float" />
        name = "toAlpha" format = "float" />
    
  • 1
  • ,
  • 4
  • (2)属性の使用:
    "1.0"
        android:toAlpha = "0.7"/>
  • 1
  • ,
  • 6.integer:整数値です.
    (1)属性定義:
    name = "AnimatedRotateDrawable">
        name = "visible" />
        name = "frameDuration" format="integer" />
        name = "framesCount" format="integer" />
        name = "pivotX" />
        name = "pivotY" />
        name = "drawable" />
    
  • 1
  • ,
  • 4
  • 5
  • ,
  • ,
  • 8
  • (2)属性の使用:
    rotate
        xmlns:android="http://schemas.android.com/apk/res/android"  
        android:drawable = "@drawable/  ID"  
        android:pivotX = "50%"  
        android:pivotY = "50%"  
        android:framesCount = "12"  
        android:frameDuration = "100"/>
  • 1
  • ,
  • 4
  • 5
  • ,
  • ,
  • 7.string:文字列.
    (1)属性定義:
    <declare-styleable name = "MapView">
        "apiKey" format = "string" />
    declare-styleable>
  • 1
  • ,
  • (2)属性の使用:
    <com.google.android.maps.MapView
        android:layout_width = "fill_parent"
        android:layout_height = "fill_parent"
        android:apiKey="0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g"/>
  • 1
  • ,
  • 4
  • 8.fraction:百分率.
    (1)属性定義:
    name="RotateDrawable">
        name = "visible" />
        name = "fromDegrees" format = "float" />
        name = "toDegrees" format = "float" />
        name = "pivotX" format = "fraction" />
        name = "pivotY" format = "fraction" />
        name = "drawable" />
    
  • 1
  • ,
  • 4
  • 5
  • ,
  • ,
  • 8
  • (2)属性の使用:
    <rotate
        xmlns:android = "http://schemas.android.com/apk/res/android" 
        android:interpolator = "@anim/  ID"
        android:fromDegrees = "0" 
        android:toDegrees = "360"
        android:pivotX = "200%"
        android:pivotY = "300%" 
        android:duration = "5000"
        android:repeatMode = "restart"
        android:repeatCount = "infinite"/>
  • 1
  • ,
  • 4
  • 5
  • ,
  • ,
  • 8
  • 9,
  • 10
  • 9.enum:列挙値.
    (1)属性定義:
    <declare-styleable name="  ">
        <attr name="orientation">
            <enum name="horizontal" value="0" />
            <enum name="vertical" value="1" />
        attr>            
    /declare-styleable>
  • 1
  • ,
  • 4
  • 5
  • ,
  • (2)属性の使用:
    "http://schemas.android.com/apk/res/android"
        android:orientation = "vertical"
        android:layout_width = "fill_parent"
        android:layout_height = "fill_parent">
     
  • 1
  • ,
  • 4
  • 5
  • ,
  • 10.フラグ:ビットまたは演算.
    (1)属性定義:
    name="  ">
        name="windowSoftInputMode">
            name = "stateUnspecified" value = "0" />
            name = "stateUnchanged" value = "1" />
            name = "stateHidden" value = "2" />
            name = "stateAlwaysHidden" value = "3" />
            name = "stateVisible" value = "4" />
            name = "stateAlwaysVisible" value = "5" />
            name = "adjustUnspecified" value = "0x00" />
            name = "adjustResize" value = "0x10" />
            name = "adjustPan" value = "0x20" />
            name = "adjustNothing" value = "0x30" />
                 
    
  • 1
  • ,
  • 4
  • 5
  • ,
  • ,
  • 8
  • 9,
  • 10
  • 11
  • (2)属性の使用:
    name = ".StyleAndThemeActivity"
        android:label = "@string/app_name"
        android:windowSoftInputMode = "stateUnspecified | stateUnchanged | stateHidden">
        
            name = "android.intent.action.MAIN" />
            name = "android.intent.category.LAUNCHER" />
        
    
  • 1
  • ,
  • 4
  • 5
  • ,
  • ,
  • 8
  • 9,
  • 注意:  属性定義の場合は、複数の種類の値を指定できます.  (1)属性定義:
    <declare-styleable name = "  ">
        "background" format = "reference|color" />
    declare-styleable>
  • 1
  • ,
  • (2)    :
    
    "42dip"
        android:layout_height = "42dip"
        android:background = "@drawable/  ID|#00FF00"
    />
  • 1
  • ,
  • 4
  • 5