1 定义一个样式
<style name="ProgressBar_Mini" parent="@android:style/Widget.ProgressBar.Horizontal">
<item name="android:maxHeight">50dip</item>
<item name="android:minHeight">28dip</item>
<item name="android:indeterminateOnly">false</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
<item name="android:progressDrawable">@drawable/progressbar_mini</item>
</style>
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#F5F5F5"
android:startColor="#BEBEBE" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="0dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#165CBC"
android:startColor="#85B0E9" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#165CBC"
android:startColor="#85B0E9" />
</shape>
</clip>
</item>
<item
android:id="@android:id/background"
android:drawable="@drawable/layout_topbar">
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/alter_login_pwd">
</item>
android:progressDrawable="@drawable/。。。。。" 指定这个属性 ok 就搞定了
<item android:id="@android:id/background" android:drawable="@drawable/progressbar_indeter1">
</item>
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/progressbar_indeter2">
</item>
<item android:id="@android:id/progress" android:drawable="@drawable/progressbar_back">
</item>
android:oneshot="false">
<item android:drawable="@drawable/progressbar_indeter1"
android:duration="100" />
<item android:drawable="@drawable/progressbar_indeter2"
android:duration="100" />
<item android:drawable="@drawable/progressbar_indeter3"
android:duration="100" />
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_color_horizontal</item>
</style>(样式 即 将你组件中的属性值抽出来作为统一使用定义成样式,最后放在style中)
一、通过动画实现
<item android:duration="150" android:drawable="@drawable/loading_01" />
<item android:duration="150" android:drawable="@drawable/loading_02" />
<item android:duration="150" android:drawable="@drawable/loading_03" />
<item android:duration="150" android:drawable="@drawable/loading_04" />
<item android:duration="150" android:drawable="@drawable/loading_05" />
<item android:duration="150" android:drawable="@drawable/loading_06" />
<item android:duration="150" android:drawable="@drawable/loading_07" />
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:indeterminate="false" android:indeterminateDrawable="@anim/loading" />
<resources>
</resources>
然后drawable 新建 ProgressBar_Mini 。。代码如下:::
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
</layer-list>
然后在布局里 把样式给引进来就可以了
2 是利用图片来自定义
drawable 下新建
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
</layer-list>
然后在布局制定 :
1 2都是制作水平进度条
-------------------------------------------------------------------------------------------------------
三、反方向进行滚动:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
</layer-list> 【其中 mCount = 0; 滚动条setProgress(mCount--); 】
四:不定进度的进度条
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
</animation-list>
【特殊之处是这个放在android:indeterminateDrawable中】
将android:progressDrawable 属性和style合二为一:
<style name="progressBarHorizontal_color" parent="android:Widget.ProgressBar.Horizontal">
定义res/anim/loading.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
</animation-list>
在layout文件中引用如下:
<ProgressBar android:id="@+id/loading_process_dialog_progressBar"