转!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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章