1.效果

2.進度條背景drawable檔案
結束後可以恢複原背景.
1 <?xml version="1.0" encoding="utf-8"?>
2 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
3 <item android:id="@+id/background">
4 <shape
5 android:layout_width="wrap_content"
6 android:shape="rectangle">
7 <corners android:radius="12dp" />
8 <stroke android:color="#dcdcdc" android:width="1px" ></stroke>
9 <solid android:color="#f7f7f7" />
10 </shape>
11 </item>
12 <item android:id="@+id/progressing"
13 android:top="2px"
14 android:right="2px"
15 android:bottom="2px"
16 android:left="2px">
17 <clip
18 android:clipOrientation="horizontal"
19 android:gravity="left" android:shape="rectangle">
20 <shape>
21 <corners android:radius="12dp" />
22 <solid android:color="#fee2cd" />
23 </shape>
24 </clip>
25 </item>
26 </layer-list>
3.更新進度
在進度更新代碼裡 計算出進度值pro,然後更新.
1 LayerDrawable ld = (LayerDrawable) view.getBackground();
2 ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(R.id.progressing);
3 clipDrawable.setLevel(100 * pro);
4.下載下傳
https://gitee.com/xi/any-view-progress.git