[b][size=medium]ProgressBar的基本使用[/size][/b]
可以参考这个:[url]http://www.eoeandroid.com/thread-1081-1-1.html[/url]
[b][size=medium]使用自定义的progressDrawable[/size][/b]
最终效果:
[img]http://dl.iteye.com/upload/attachment/601238/5336aed7-fc9e-3a14-bed0-fec1327389f3.png[/img]
创建一个LayerDrawable:/res/drawable/progress.xml
接下来在布局文件的ProgressBar中引用该drawable就ok了,/res/layout/test.xml
可以参考这个:[url]http://www.eoeandroid.com/thread-1081-1-1.html[/url]
[b][size=medium]使用自定义的progressDrawable[/size][/b]
最终效果:
[img]http://dl.iteye.com/upload/attachment/601238/5336aed7-fc9e-3a14-bed0-fec1327389f3.png[/img]
创建一个LayerDrawable:/res/drawable/progress.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 背景图片 -->
<item
android:id="@android:id/background"
android:drawable="@drawable/loading_background" />
<!-- 进度图片 -->
<item
android:id="@android:id/progress">
<clip>
<!-- 为了防止bitmap被拉伸,所以没有直接用clip的android:drawable属性-->
<bitmap
android:src="@drawable/loading_bar"
android:gravity="center" />
</clip>
</item>
</layer-list>
接下来在布局文件的ProgressBar中引用该drawable就ok了,/res/layout/test.xml
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ProgressBar
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="180dp"
android:layout_height="40dp"
android:max="100"
android:progress="80"
android:progressDrawable="@drawable/progress" />
</merge>