1 Introduction
ProgressBar can show progress. Figure it is a part of the black ProgressBar, in FIG Second progress of the ProgressBar 40% ( examples of possible bit ugly ).
The common attributes ProgressBar xml:
max: maximum value of the specified progress bar.
progress: Specifies default value for the progress bar, the code can be set by the progress setProgress () method.
progressDrawable: Specifies the progress of the picture, not with the general picture, use the hierarchical graph, see examples of the latter.
style: style specifies the shape of a progress bar. progressBarStyleHorizontal represents horizontal shape, progressBarStyle shape indicates a circle. If the style is progressBarStyle a circle shape, and set the maximum value of the schedule will be invalid.
2. Examples
- Here is an example of the hierarchical graph. The first item specified background, here designated a Shape rounded, almost black (as Figure 1). The second item displays the progress of the specified color or picture.
<?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>
<solid android:color="#282929"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<color android:color="#FA9601"/>
</clip>
</item>
</layer-list>
- The following code uses the ProgressBar is xml.
<ProgressBar
android:id="@+id/pb_demo"
android:layout_width="match_parent"
android:layout_height="20dp"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/custom_process_bar_yellow"
style="?android:progressBarStyleHorizontal"/>