The value that the format option can take when Android custom properties

Source: Internet
Author: User

1. Reference: Refer to a resource ID.

(1) Attribute definition:

    1. <declare-styleable name= "Name" >
    2. <attr format= "Reference" name= "background"/>
    3. </declare-styleable>


(2) attribute use:

    1. <imageview
    2. Android:layout_width= "42dip"
    3. android:layout_height= "42dip"
    4. android:background= "@drawable/Picture id"/>


2. Color: Colour value.

(1) Attribute definition:

    1. <declare-styleable name= "Name" >
    2. <attr format= "Color" name= "TextColor"/>
    3. </declare-styleable>


(2) attribute use:

    1. <textview
    2. Android:layout_width= "42dip"
    3. android:layout_height= "42dip"
    4. Android:textcolor= "#00FF00"/>


3. Boolean: Boolean value.

(1) Attribute definition:

    1. <declare-styleable name= "Name" >
    2. <attr format= "boolean" name= "Focusable"/>
    3. </declare-styleable>


(2) attribute use:

    1. <button
    2. Android:layout_width= "42dip"
    3. android:layout_height= "42dip"
    4. Android:focusable= "true"/>


4. Dimension: Dimension value.

(1) Attribute definition:

    1. <declare-styleable name= "Name" >
    2. <attr format= "Dimension" Name= "Layout_width"/>
    3. </declare-styleable>


(2) attribute use:

    1. <button
    2. Android:layout_width= "42dip"
    3. android:layout_height= "42dip"/>


5. Float: floating-point value.

(1) Attribute definition:

    1. <declare-styleable name= "Alphaanimation" >
    2. <attr format= "float" name= "Fromalpha"/>
    3. <attr format= "float" name= "Toalpha"/>
    4. </declare-styleable>


(2) attribute use:

    1. <alpha
    2. Android:fromalpha= "1.0"
    3. Android:toalpha= "0.7"/>


6. Integer: Integer value.

(1) Attribute definition:

    1. <declare-styleable name= "Animatedrotatedrawable" >
    2. <attr format= "integer" name= "Frameduration"/>
    3. <attr format= "integer" name= "Framescount"/>
    4. </declare-styleable>


(2) attribute use:

    1. <animated-rotate
    2. android:frameduration= "100"
    3. Android:framescount= "12"
    4. />


7. String: Strings.

(1) Attribute definition:

    1. <declare-styleable name= "Mapview" >
    2. <attr format= "string" name= "ApiKey"/>
    3. </declare-styleable>


(2) attribute use:

    1. <com.google.android.maps.mapview
    2. Android:layout_width= "Fill_parent"
    3. android:layout_height= "Fill_parent"
    4. android:apikey= "0jokq80od1jl9c6haja99ugxcris2cgjko_bc_g"/>


8. Fraction: percentage.

(1) Attribute definition:


    1. <declare-styleable name= "Rotatedrawable" >
    2. <attr format= "fraction" name= "Pivotx"/>
    3. <attr format= "fraction" name= "Pivoty"/>
    4. </declare-styleable>


(2) attribute use:

    1. <rotate
    2. android:pivotx= "200%"
    3. Android:pivoty= "300%"
    4. />


9. Enum: enumeration value.

(1) Attribute definition:

    1. <declare-styleable name= "Name" >
    2. <attr name= "Orientation" >
    3. <enum name= "Horizontal" value= "0"/>
    4. <enum name= "Vertical" value= "1"/>
    5. </attr>
    6. </declare-styleable>


(2) attribute use:

    1. <linearlayout
    2. android:orientation= "Vertical" >
    3. </LinearLayout>


Flag: Bit or operation.

(1) Attribute definition:

  1. <declare-styleable name= "Name" >
  2. <attr name= "Windowsoftinputmode" >
  3. <flag name= "stateunspecified" value= "0"/>
  4. <flag name= "stateunchanged" value= "1"/>
  5. <flag name= "Statehidden" value= "2"/>
  6. <flag name= "Statealwayshidden" value= "3"/>
  7. <flag name= "statevisible" value= "4"/>
  8. <flag name= "statealwaysvisible" value= "5"/>
  9. <flag name= "adjustunspecified" value= "0x00"/>
  10. <flag name= "adjustresize" value= "0x10"/>
  11. <flag name= "Adjustpan" value= "0x20"/>
  12. <flag name= "adjustnothing" value= "0x30"/>
  13. </attr>
  14. </declare-styleable>


(2) attribute use:

    1. <activity
    2. Android:windowsoftinputmode= "Stateunspecified | stateunchanged | Statehidden ">
    3. </activity>


Note: You can specify multiple types of values when you define a property:

(1) Attribute definition:

    1. <declare-styleable name= "Name" >
    2. <attr format= "Reference|color" name= "Background"/>
    3. </declare-styleable>


(2) attribute use:

    1. <imageview
    2. Android:layout_width= "42dip"
    3. android:layout_height= "42dip"
    4. android:background= "@drawable/Picture id| #00FF00"/>

The value that the format option can take when Android custom properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.