轉!Android進度條修改教程(顏色,高度)

android進度條大致分爲兩種,水平進度條和圓形進度條。我們一般需要改的就是水平進度條,因爲這個不是替換圖片可以做到的,所以發下此教程。
首先,準備工作就是建立java運行環境,尋找一個順手的反編譯工具,這個不做過多贅述。具體請去谷歌一下。然後你需要複製出ROM自帶的framework-res.apk,反編譯之。
這時候進入正題,替換進度條需要修改兩個xml文件,分別是:
framework-res.apk/res/drawable/progress_horizontal.xml (定義進度條顏色)
framework-res.apk/res/value/styles.xml(定義進度條佈局)
首先,progress_horizontal.xml 這裏,你可以改的是進度條的邊框弧度
<item android:id=”@id/background”>
<shape>
<corners android:radius=”4.659973dip” />(半徑自定義)
進度條的顏色
</corners>
<gradient
android:startColor=”#FFFFFFFF”(顏色自定義)
android:endColor=”#FFFFFFFF”(顏色自定義)
android:angle=”270.0″
android:centerY=”0.75″
android:centerColor=”#FFFFFFFF”(顏色自定義)
<item android:id=”@id/progress”>
<clip>
<shape>
<corners android:radius=”4.659973dip” />
<gradient
android:startColor=”#ff61bbff”
android:endColor=”#ff0091ff”
android:angle=”270.0″
android:centerY=”0.75″
android:centerColor=”#ff32a7ff” />(這裏的三個顏色定義爲進度條背景)
做完了這些,你就完成了一半以上的工作了,因爲這些顏色是配色原理,很難搞定。
接下來就是在styles.xml里布局了。
首先查找progressbar,找到這一行
<style name=”Widget.ProgressBar.Horizontal” parent=”@style/Widget.ProgressBar”>
<item name=”maxHeight”>20.0dip</item>
<item name=”indeterminateOnly”>false</item>
<item name=”indeterminateDrawable”>@drawable/progress_indeterminate_horizontal</item>
<item name=”progressDrawable”>@drawable/progress_horizontal</item>
<item name=”minHeight”>20.0dip</item>
</style>
將兩個20.0dip改爲10.0dip(這是我自己改的高度,各位可憑自己的喜好自行修改)。這裏進度條的高度就搞定了。
這裏還有一個問題就是,seekbar和progressbar的區別。
seekbar指的是拖動條,比如你打開設置,聲音,音量的時候,看到的那個可以拖動的進度條。
所以緊隨上一行代碼之後,我們看到了下面的:
<style name=”Widget.SeekBar” parent=”@style/Widget”>
<item name=”focusable”>true</item>
<item name=”maxHeight”>20.0dip</item>
<item name=”indeterminateOnly”>false</item>
<item name=”indeterminateDrawable”>@drawable/progress_horizontal</item>
<item name=”progressDrawable”>@drawable/progress_horizontal</item>
<item name=”minHeight”>20.0dip</item>
<item name=”thumb”>@drawable/seek_thumb</item>
<item name=”thumbOffset”>8.0dip</item>
同樣的,將兩個20.0dip改爲10.0dip,截止到這裏,進度條的修改就已經完成了。編譯回去,替換進系統,重啓,OK。



原文地址:http://unetman.com/posts/2012_01_06_59.shtml
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章