Create
a drawable in your Drawable folder called vertical_progress_bar.xml:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 |
<?xml version="1.0"
encoding="utf-8"
?> <item android:id="@android:id/background"> <shape> <corners android:radius="5dip"
/> <gradient android:startColor="#ff9d9e9d" android:centerColor="#ff5a5d5a" android:centerY="0.75" android:endColor="#ff747674" android:angle="180" /> </shape> </item> <item android:id="@android:id/secondaryProgress"> <clip android:clipOrientation="vertical"
android:gravity="bottom"> <shape> <corners android:radius="5dip"
/> <gradient android:startColor="#80ffd300" android:centerColor="#80ffb600" android:centerY="0.75" android:endColor="#a0ffcb00" android:angle="180" /> </shape> </clip> </item> <item android:id="@android:id/progress"> <clip android:clipOrientation="vertical"
android:gravity="bottom"> <shape> <corners android:radius="5dip"
/> <gradient android:startColor="#ffffd300" android:centerColor="#ffffb600" android:centerY="0.75" android:endColor="#ffffcb00" android:angle="180" /> </shape> </clip> </item></layer-list> |
Create
a styles.xml file in the Resource/Values folder:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 |
<?xml version="1.0"
encoding="utf-8"
?><resources> <style name="Widget"> </style> <style name="Widget.ProgressBar"> <item name="android:indeterminateOnly">true</item> <item name="android:indeterminateBehavior">repeat</item> <item name="android:indeterminateDuration">3500</item> <item name="android:minWidth">48dip</item> <item name="android:maxWidth">48dip</item> <item name="android:minHeight">48dip</item> <item name="android:maxHeight">48dip</item> </style> <style name="Widget.ProgressBar.Vertical"> <item name="android:indeterminateOnly">false</item> <item name="android:progressDrawable">@drawable/vertical_progress_bar</item> <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item> <item name="android:minWidth">1dip</item> <item name="android:maxWidth">12dip</item> </style></resources> |
Now you should be able to use something like, in your layout:
|
1
2
3
4
5 |
<ProgressBar android:layout_width="12dip" android:layout_height="300dip" style="@style/Widget.ProgressBar.Vertical" android:id="@+id/progressBar2"/> |
Make ProgressBar Vertical,布布扣,bubuko.com
原文:http://www.cnblogs.com/tt_mc/p/3626597.html