Attr Custom Properties in Android

Source: Internet
Author: User

<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_height="wrap_content">

The second line is a custom label. Format as above, where the "Xmlns:wen" Colon is followed by a label name, when used below (only available for the current file)
 <textview Wen: property name/> "Com.iteye.googlers" is your project package name. 
1. Reference: Refer to a resource ID.     (1) attribute definitions:            <declare-styleable name = "Name" >                   <attr name = "Background" format = "Reference"/>    &NBSP ;       </declare-styleable>    (2) properties using:            <imagev iew                     android:layout_width = "42dip"                      android:layout_height = "42dip"                      android:background = "@drawable/image ID"           &N Bsp         &NBSP;/&GT;&NBSP;2. Color: Colour value.     (1) attribute definitions:            <declare-styleable name = "Name" >                   <attr NamE = "TextColor" format = "color"/>            </declare-styleable>    (2 ) Properties using:            <TextView                     android:layout_width = "42dip"                      an Droid:layout_height = "42dip"                      android:textcolor = "#00FF00"                      />  3. Boolean: Boolean value.     (1) attribute definitions:            <declare-styleable name = "Name" >                <attr name = "focusable" format = "boolean"/>            </declare-styleable>    (2) properties using:            <Button                   android:layout_width = "42dip"                   and Nbsp;android:layout_height = "42dip"                   &NBSP;ANDROID:FOCUSABL E = "true"                    /> 4. Dimension: Dimension value.       (1) attribute definitions:             <declare-styleable name = "Name" >  &N Bsp                <attr name = "layout_width" format = "Dimension"/>  &NB Sp         </declare-styleable>    (2) properties using:            < button                   android:layout_width = "42dip"     &NB Sp              android:layout_height = ' 42dip '             & nbsp    />&Nbsp; 5. float: floating-point value.     (1) attribute definitions:            <declare-styleable name = "Alphaanimation" >  &n Bsp                <attr name = "Fromalpha" format = "float"/>    &NB Sp              <attr name = "Toalpha" format = "float"/>      &NBSP ;     </declare-styleable>    (2) attribute use:            <alpha  nbsp                android:fromalpha = "1.0"                    android:toalpha = ' 0.7 '                   &NBSP;/&G T; 6. Integer: Integer value.     (1) attribute definitions:            <declare-styleable name = "Animatedrotatedrawable" >                   &NBSP;&LT;ATTR name = "Visible"/>                   <attr name = "Frameduration" forma t= "integer"/>                   <attr name = "Framescount" format = "integer"/>                   <attr name = "Pivotx"/>                   <attr name = "Pivoty"/>        &N Bsp          <attr name = "drawable"/>            &LT;/DECLARE-S tyleable>    (2) properties using:            <animated-rotate      &NBSP ;            xmlns:android = "Http://schemas.android.com/apk/res/android"                     android:drawable = "@drawable/image ID"      &NBS P       &nbsp      android:pivotx = "50%"                    &NBSP;ANDR Oid:pivoty = "50%"                     android:framescount = "12" & nbsp;                   android:frameduration = "+"     &NBSP ;              /> 7. String: Strings.     (1) attribute definitions:            <declare-styleable name = "Mapview" >    &N Bsp              <attr name = "ApiKey" format = "string"/>      &NBSP ;     </declare-styleable>    (2) properties using:            < com.google.android.maps.mapview                    Android:layout_ width = "Fill_parent"                 &nbsp   Android:layout_height = "fill_parent"                     Android: ApiKey = "0jokq80od1jl9c6haja99ugxcris2cgjko_bc_g"                    /& Gt; 8. Fraction: percentage.       (1) attribute definitions:            <declare-styleable name= "rotatedrawable" >& nbsp                  <attr name = "visible"/>        & nbsp          <attr name = "fromdegrees" format = "float"/>          & nbsp        <attr name = "todegrees" format = "float"/>            &NB Sp      <attr name = "Pivotx" format = "fraction"/>              &NB Sp    <attr name = "Pivoty" format = "fraction"/>        &NBsp          <attr name = "drawable"/>            &LT;/DECLARE-S tyleable>     (2) properties using:            <rotate        &N Bsp        xmlns:android = "http://schemas.android.com/apk/res/android"         &NBS P     Android:interpolator = "@anim/animation ID"                 &NBSP;ANDROID:FRO Mdegrees = "0"               android:todegrees = "Up"         &NBS P        android:pivotx = ' 200% '                 &NBSP;ANDROID:PI Voty = "300%"               android:duration = "we"         &NBSP ;        android:repeatmode = ' restart '                  and Roid:rePeatcount = "Infinite"                /> 9. Enum: enumeration value.     (1) attribute definitions:            <declare-styleable name= "name" >      &N Bsp            <attr name= "orientation" >              and nbsp           <enum name= "horizontal" value= "0"/>            &NB Sp             <enum name= "vertical" value= "1"/>          &NBSP ;        </attr>                      &NBSP ; </declare-styleable>    (2) properties using:            <LinearLayout                    xmlns:android = "Http://schemas.android.com/apk/res/android" & nbsp                   android:orientation = "vertical"               &NBSP ;     Android:layout_width = "fill_parent"                     (AN) Droid:layout_height = "Fill_parent"                     >            &LT;/LINEARLAYOUT&GT;&NBSP;10. Flag: Bit or operation.       (1) attribute definitions:             <declare-styleable name= "name" >  & nbsp                 <attr name= "Windowsoftinputmode" >                            <flag name = "Stateunspecified" value = "0"/&gt ;                            <flag name = "Stateu Nchanged "value =" 1 "/>            &NBsp               <flag name = "Statehidden" value = "2"/>      &NBSP ;                     <flag name = "Statealwayshidden" value = "3"/&gt ;                            <flag name = "Statev Isible "value =" 4 "/>                            <flag name = "Statealwaysvisible" value = "5"/>                  &NBS P         <flag name = "Adjustunspecified" value = "0x00"/>          &NB Sp                 <flag name = "Adjustresize" value = "0x10"/>    & nbsp                       <flag name = "Adjustpan" value = "0x20"/& gt;&nbsp                           <flag name = "Adjustnothing" Value = "0x30"/>                     </attr>   &NBS P                  </declare-styleable> (2) Properties using:
<Activity Android:name=". Styleandthemeactivity"Android:label="@string/app_name"Android:windowsoftinputmode="stateunspecified | stateunchanged | Statehidden"> <intent-filter> <action android:name ="Android.intent.action.MAIN"/> <category android:name ="Android.intent.category.LAUNCHER"/> </intent-filter> </activity>

Note: You can specify multiple types of values when you define a property. (1) Property Definition: <declare-styleable name = "name" > <attr name = "Background" format = "Referen Ce|color "/> </declare-styleable> (2) Property usage: <imageview android:la Yout_width = "42dip" android:layout_height = "42dip" Android:background = "@drawab le/picture id| #00FF00 "/>

Attr Custom Properties in Android

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.