中文字幕日韩精品一区二区免费_精品一区二区三区国产精品无卡在_国精品无码专区一区二区三区_国产αv三级中文在线

Android自定義控件之自定義屬性format詳解

Android 自定義View 控件己經(jīng)不是什么新鮮話題,Android Api提供了一大堆基礎(chǔ)組件給我們,需要什么特定功能還需要我們繼承它們?nèi)缓蠖ㄖ聘迂S富的功能。這里介紹一下自定義屬性format

10年積累的網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有松滋免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

  1. reference:參考某一資源ID。

    (1)屬性定義:

            <declare-styleable name = "名稱">

                   <attr name = "background" format = "reference" />

            </declare-styleable>

    (2)屬性使用:

             <ImageView

                     android:layout_width = "42dip"
                     android:layout_height = "42dip"
                     android:background = "@drawable/圖片ID"

                     />

2. color:顏色值。

    (1)屬性定義:

            <declare-styleable name = "名稱">

                   <attr name = "textColor" format = "color" />

            </declare-styleable>

    (2)屬性使用:

            <TextView

                     android:layout_width = "42dip"
                     android:layout_height = "42dip"
                     android:textColor = "#00FF00"

                     />

3. boolean:布爾值。

    (1)屬性定義:

            <declare-styleable name = "名稱">

                   <attr name = "focusable" format = "boolean" />

            </declare-styleable>

    (2)屬性使用:

            <Button

                    android:layout_width = "42dip"
                    android:layout_height = "42dip"

                    android:focusable = "true"

                    />

4. dimension:尺寸值。

    (1)屬性定義:

            <declare-styleable name = "名稱">

                   <attr name = "layout_width" format = "dimension" />

            </declare-styleable>

    (2)屬性使用:

            <Button

                    android:layout_width = "42dip"
                    android:layout_height = "42dip"

                    />

5. float:浮點(diǎn)值。

    (1)屬性定義:

            <declare-styleable name = "AlphaAnimation">

                   <attr name = "fromAlpha" format = "float" />
                   <attr name = "toAlpha" format = "float" />

            </declare-styleable>

    (2)屬性使用:

            <alpha
                   android:fromAlpha = "1.0"
                   android:toAlpha = "0.7"

                   />

6. integer:整型值。

    (1)屬性定義:

            <declare-styleable name = "AnimatedRotateDrawable">

                   <attr name = "visible" />
                   <attr name = "frameDuration" format="integer" />
                   <attr name = "framesCount" format="integer" />
                   <attr name = "pivotX" />
                   <attr name = "pivotY" />
                   <attr name = "drawable" />

            </declare-styleable>

    (2)屬性使用:

            <animated-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"

                   />

7. string:字符串。

    (1)屬性定義:

            <declare-styleable name = "MapView">
                   <attr name = "apiKey" format = "string" />
            </declare-styleable>

    (2)屬性使用:

            <com.google.android.maps.MapView
                    android:layout_width = "fill_parent"
                    android:layout_height = "fill_parent"
                    android:apiKey = "0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g"

                    />

8. fraction:百分?jǐn)?shù)。

    (1)屬性定義:

            <declare-styleable name="RotateDrawable">
                   <attr name = "visible" />
                   <attr name = "fromDegrees" format = "float" />
                   <attr name = "toDegrees" format = "float" />
                   <attr name = "pivotX" format = "fraction" />
                   <attr name = "pivotY" format = "fraction" />
                   <attr name = "drawable" />
            </declare-styleable>

    (2)屬性使用:

            <rotate

                   xmlns:android = "http://schemas.android.com/apk/res/android" 
               android:interpolator = "@anim/動(dòng)畫(huà)ID"

                   android:fromDegrees = "0" 
               android:toDegrees = "360"

                   android:pivotX = "200%"

                   android:pivotY = "300%" 
               android:duration = "5000"

                   android:repeatMode = "restart"

                   android:repeatCount = "infinite"

                   />

9. enum:枚舉值。

    (1)屬性定義:

            <declare-styleable name="名稱">
                   <attr name="orientation">
                          <enum name="horizontal" value="0" />
                          <enum name="vertical" value="1" />
                   </attr>            

            </declare-styleable>

    (2)屬性使用:

            <LinearLayout

                    xmlns:android = "http://schemas.android.com/apk/res/android"
                    android:orientation = "vertical"
                    android:layout_width = "fill_parent"
                    android:layout_height = "fill_parent"
                    >
            </LinearLayout>

10. flag:位或運(yùn)算。

     (1)屬性定義:

             <declare-styleable name="名稱">
                    <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>         

             </declare-styleable>

     (2)屬性使用:

            <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>

     注意:

     屬性定義時(shí)可以指定多種類型值。

    (1)屬性定義:

            <declare-styleable name = "名稱">

                   <attr name = "background" format = "reference|color" />

            </declare-styleable>

    (2)屬性使用:

             <ImageView

                     android:layout_width = "42dip"
                     android:layout_height = "42dip"
                     android:background = "@drawable/圖片ID|#00FF00"

                     />

網(wǎng)頁(yè)題目:Android自定義控件之自定義屬性format詳解
標(biāo)題來(lái)源:http://www.rwnh.cn/article42/gopdec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)商城網(wǎng)站、App設(shè)計(jì)、用戶體驗(yàn)響應(yīng)式網(wǎng)站、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)
莱阳市| 信丰县| 焦作市| 东山县| 岱山县| 从江县| 林芝县| 无棣县| 施甸县| 永胜县| 鄂尔多斯市| 和平县| 宁海县| 阿坝县| 嵊泗县| 屏边| 斗六市| 加查县| 施甸县| 衡南县| 茂名市| 永兴县| 盐城市| 虞城县| 桂平市| 锡林郭勒盟| 阳朔县| 石景山区| 长白| 凤冈县| 耿马| 淮阳县| 清河县| 那曲县| 齐齐哈尔市| 简阳市| 泰州市| 吐鲁番市| 九龙城区| 鹿泉市| 开原市|