转载请注明出处。付小华的移动开发微博:http://blog.csdn.net/klxh2009
很少写博客,今天来一个。先看效果图:
项目文件结构:
1、drawable
2、stytles
3、layout
一、先看layout:
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B4E7BA"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/myprogressbar"
style="@style/style_myprogressbar"
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_margin="20dp"
android:background="@drawable/shape_pb_bg"
android:max="100"
android:progress="40" />
</LinearLayout></span>
<style name="style_myprogressbar" parent="@android:style/Widget.ProgressBar.Horizontal">
<item name="android:maxHeight">50dip</item>
<item name="android:minHeight">10dip</item>
<item name="android:indeterminateOnly">false</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
<item name="android:progressDrawable">@drawable/shape_pb_bg</item>
</style>
三、drawable下的shape_pb_bg:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 底色 -->
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#FFFFFF"
android:startColor="#FFFFFF" />
</shape>
</item>
<!-- 进度 -->
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#1D00FF"
android:startColor="#1D00FF" />
</shape>
</clip>
</item>
</layer-list>
OK,有这些就够了,谢谢。