Attr Custom Properties in Android

Source: Internet
Author: User
<span id="Label3"></p><linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:wen=http://schemas.android.com /apk/res/com.iteye.googlers android:orientation= "vertical" android:layout_width= "fill_parent" Android:layout_heig ht= "wrap_content" ><br>The second line is a custom label.<br>Format as above, where the "xmlns:wen" colon is followed by a label name, when used below (only available for the current File)<br><textview Wen: Property Name/><br>"com.iteye.googlers" is the name of your project Package.<br> <br>1. reference: refer to a resource ID. (1) Property definition: <declare-styleable name = "name" > <attr name = "background" format = "refer ence "/> </declare-styleable> (2) property usage: <imageview Android:lay Out_width = "42dip" Android:layout_height = "42dip" Android:background = "@drawa Ble/image ID "/><br>2. Color: colour Value. (1) Property definition: <declare-styleable name = "name" > <attr name = "textcolor" format = "color" /> </declare-styleable> (2) Property usage: <textview Android:layout_wi                      DTH = "42dip" Android:layout_height = "42dip" Android:textcolor = "#00FF00" /><br>  3. Boolean: Boolean Value.     (1) attribute definition:             <declare-styleable name = "name" >     &nbsp ;           <attr name = ' focusable ' format = ' boolean '/>             </declare-styleable>     (2) property use:             <button   &NBS P                android:layout_width = "42dip"           & nbsp        android:layout_height = "42dip"                    android:focusable = "true"                    />   4. Dimension: Dimension Value.       (1) attribute definition:              <declare-styleable name = "name" >                    <attr name = "layout_width" format= "dimension"/>             </declare-styleable>     (2) attribute use:   &NB Sp         <button                    android:layout _width = "42dip"                    android:layout_height = "42dip" &nbs P                /><br>  5. Float: floating-point Value.     (1) attribute definition:             <declare-styleable name = "alphaanimation" >                    <attr name = "fromalpha" format = "float"/>   &N Bsp                <attr name = "toalpha" format = "float"/>     &NBS P       </declare-styleable>     (2) Properties use:             <alpha                    android:fromalpha = "1.0"       &NBSP ;            android:toalpha = "0.7"                 & nbsp  />   6. Integer: integer Value.     (1) attribute definition:             <declare-styleable name = "animatedrotatedrawable" >                    <attr name = "visible"/>                    <attr name = "framedur ation "format=" integer "/>                   &NBSP;&LT;ATTR name =" frames Count "format=" integer "/>                    <attr name =" pivotx "/>                    <attr name =" pivoty "/>                    <attr name = "drawable"/>             </declare-styleable>     (2) property use:             <animated-rotate &N Bsp                  xmlns:android = "http://schemas.android.com/apk/res/ Android                      android:drawable = "@drawable/image id" & nbsp                   android:pivotx = "50%"               &N Bsp      android:pivoty = ' 50% '                    and Roid:framescount = "                     android:frameduration = "$"                    />   7. String: strings.     (1) attribute definition:             <declare-styleable name = "mapview" >                    <attr name = "apiKey" format = "string"/>     &NBS P       </declare-styleable>     (2) Properties use:             &LT;COM.G Oogle.android.maps.MapView                     Android:layout_width = "f Ill_parent "                   android:layout_height = "fill_parent"                     Android:apikey = "0jokq80od1jl9c6haja99ugxcris2cgjko_bc_g"                    /><br>8. Fraction: Percentage.                    (1) attribute definition: <declare-styleable name= "rotatedrawable" > <attr name = "visible"/> <attr name = "fromdegrees" format = "float"/> <attr name = "todegrees" forma t = "float"/> <attr name = "pivotx" format = "fraction"/> <attr name = "pivoty" format = "fraction"/> <attr name = "drawable"/> </declare-styleable ><br>(2) attribute use: <rotate xmlns:android = "http://schemas.android.com/apk/res/android" Android:interpolator = "@anim/animation id" android:fromdegrees = "0" Android:todegrees = "36 0 "android:pivotx =" 200% "android:pivoty =" 300% "android:duration =" 5 "android:repeatmode =" restart "android:repeatcount =" Infinite "/&G T<br> 9. Enum: Enumeration Value.     (1) attribute definition:             <declare-styleable name= "name" >                    <attr name= "orientation" >                           <enum name= "horizontal" value= "0"/>         &N Bsp                 <enum name= "vertical" value= "1"/>       &NBS P            </attr>                   &NBS P     </declare-styleable>     (2) Properties using:             <linearlayout                     xmlns:android = "http://schemas.android.com/apk/res /android "                    android:orientation =" vertical "  &nbsp                 Android:layout_width = "fill_parent"         & nbsp           android:layout_height = "fill_parent"                     >             </LinearLayout><br> Flag: bit or Operation.       (1) attribute definitions:              <declare-styleable name= "name" >   &N Bsp                 <attr name= "windowsoftinputmode" >       &nbsp ;                     <flag name = "stateunspecified" Value = "0"/>                             <flag name = "stateu nchanged "value =" 1 "/>                           &NB Sp <flag name = "statehidden" value = "2"/>                     &NBS P       <flag name = "statealwayshidden" value = "3"/>             &NBSP ;               <flag name = "statevisible" value = "4"/>     &NBsp                       <flag name = "statealwaysvisible" Value = "5"/>                             <flag name = "adjustunspecified" value = "0x00"/>                       &N Bsp     <flag name = "adjustresize" value = "0x10"/>                             <flag name = "adjustpan" value = "0x20"/>         &NB Sp                   <flag name = "adjustnothing" value = "0x30"/>                      </attr>          &nbs P            </declare-styleable><br>       (2) property use:             <activity           &N Bsp        android:name = ". Styleandthemeactivity "                   android:label =" @string/app_n Ame "                   android:windowsoftinputmode =" stateunspecified | stateunchanged | Statehidden >                    <intent-filter>                           <action android:name = "android.intent.act Ion. MAIN "/>                           <category Androi D:name = "android.intent.category.LAUNCHER"/>                   &NBSP;&LT ;/intent-filter>             &NBSP;&LT;/Activity>       note: You can specify multiple types of values when you define       Properties.     (1) attribute definition:             <declare-styleable name = "name" >     &nbsp ;              <attr name = "background" format = "reference|color"/>   &NBSP ;         </declare-styleable>     (2) Properties use:             &N Bsp;<imageview                      android:layout_width = "42di P "                     android:layout_height =" 42dip "  &nbs P                  android:background = "@drawable/picture id| #00FF00"                      /><p><p> Attr Custom properties in Android </p> </p></span>

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.