溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

定制progrebar-如何讓控件在2.x系統(tǒng)里顯示holo風(fēng)格(4.x系統(tǒng)下的控件風(fēng)格)

發(fā)布時(shí)間:2020-10-20 01:25:48 來(lái)源:網(wǎng)絡(luò) 閱讀:456 作者:海太帥 欄目:移動(dòng)開(kāi)發(fā)


定制progrebar,這里以progrebar(small)為例,使之在2.x系統(tǒng)里顯示holo風(fēng)格。

1)找到系統(tǒng)文件styles.xml 和themes.xml。

在目錄adt-bundle\sdk\platforms\android-19\data\res\values下找到styles.xml和  themes.xml,用Uedit打開(kāi);

2) 在系統(tǒng)的styles.xml中搜索控件名稱(chēng)progrebar,找到

“  <style name="Widget.Holo.ProgressBar.Small" parent="Widget.ProgressBar.Small">

        <item name="android:indeterminateDrawable">@android:drawable/progress_small_holo</item>

    </style>”,其中@android:drawable/progress_small_holo是屬性;

3) 復(fù)制progress_small_holo,在adt-bundle\sdk\platforms\android-19\data\res\values\drawable文件夾下搜“progress_small_holo”,

找到對(duì)應(yīng)的xml文件,拷貝到我們自己的項(xiàng)目的res下的drawable文件夾下(這個(gè)文件夾要自己建)

注意:如果屬性值為?開(kāi)頭,則使用后面字符串在先在themes.xml中搜索,重復(fù)步驟3.

xml文件內(nèi)容如下:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>

        <rotate

             android:drawable="@drawable/spinner_16_outer_holo"

             android:pivotX="50%"

             android:pivotY="50%"

             android:fromDegrees="0"

             android:toDegrees="1080" />

    </item>

    <item>

        <rotate

             android:drawable="@drawable/spinner_16_inner_holo"

             android:pivotX="50%"

             android:pivotY="50%"

             android:fromDegrees="720"

             android:toDegrees="0" />

    </item>

</layer-list>


4) 修改錯(cuò)誤。因?yàn)榭截惖膒rogress_small_holo中有張圖片spinner_16_outer_holo,需要拷貝到自己的項(xiàng)目中。

adt-bundle-windows-x86-20130917\sdk\platforms\android-18\data\res\drawable-hdpi中搜索圖片名稱(chēng)spinner_16_outer_holo,

并將其拷貝到自己的項(xiàng)目中的drawable-hdpi文件夾下;

4) 修改控件屬性。拉一個(gè) progrebar(small)控件,設(shè)置為在2.x系統(tǒng)下預(yù)覽 ,在屬性中加入

     android:indeterminateDrawable="@drawable/progress_small_holo"。


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI