转载地址:http://android-coding.blogspot.com/2013/02/implement-vertical-progressbar.html
http://stackoverflow.com/questions/3926395/android-set-a-progressbar-to-be-a-vertical-bar-instead-of-horizontal
To implement custom vertical ProgressBar, create file /res/drawable/verticalprogressbar.xml to define our progressDrawable.
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
|
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
item
android:id
=
"@android:id/background"
>
<
shape
>
<
corners
android:radius
=
"5dip"
/>
<
solid
android:color
=
"#FFFFFF"
/>
<
stroke
android:width
=
"1dp"
android:color
=
"#FF000000"
/>
</
shape
>
</
item
>
<
item
android:id
=
"@android:id/progress"
>
<
clip
android:clipOrientation
=
"vertical"
android:gravity
=
"bottom"
>
<
shape
>
<
corners
android:radius
=
"5dip"
/>
<
solid
android:color
=
"#FFBE00"
/>
<
stroke
android:width
=
"1dp"
android:color
=
"#FF000000"
/>
</
shape
>
</
clip
>
</
item
>
</
layer-list
>
|
Modify layout to include ProgressBar with android:progressDrawable="@drawable/verticalprogressbar".
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
android:layout_width
=
"match_parent"
android:layout_height
=
"match_parent"
android:orientation
=
"horizontal"
tools:context
=
".MainActivity"
>
<
ProgressBar
android:id
=
"@+id/vprogressbar"
style
=
"?android:attr/progressBarStyleHorizontal"
android:layout_width
=
"wrap_content"
android:layout_height
=
"match_parent"
android:progressDrawable
=
"@drawable/verticalprogressbar"
/>
<
Button
android:id
=
"@+id/start"
android:layout_width
=
"fill_parent"
android:layout_height
=
"wrap_content"
android:text
=
"- Start -"
/>
</
LinearLayout
>
|