赞
踩
ProgressBar
用于显示进度条,进度条有两种不同的样式,旋转和水平,通过设置style
来区分。
style="?android:attr/progressBarStyleSmall"
style="?android:attr/progressBarStyleSmallInverse"
style="?android:attr/progressBarStyleSmallTitle"
style="?android:attr/progressBarStyleLarge"
style="?android:attr/progressBarStyleLargeInverse"
style="?android:attr/progressBarStyleInverse"
progress
、secondaryProgress
、max
属性,来显示进度。<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="30"/>
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="40"
android:secondaryProgress="70"/>
shape
文件来指定进度条背景,需要配置progressDrawable
属性<ProgressBar android:layout_width="match_parent" android:layout_height="5dp" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:progress="30" android:progressDrawable="@drawable/progress_bar_bg"/> <ProgressBar android:layout_width="match_parent" android:layout_height="5dp" android:layout_marginTop="5dp" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:progress="40" android:secondaryProgress="70" android:progressDrawable="@drawable/progress_bar_bg"/>
progress_bar_bg.xml
文件<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" > <shape> <solid android:color="#ffffffff" /> </shape> </item> <item android:id="@android:id/secondaryProgress" > <clip> <shape> <solid android:color="#fff84c00" /> </shape> </clip> </item> <item android:id="@android:id/progress" > <clip> <shape> <solid android:color="#ffff8c00" /> </shape> </clip> </item> </layer-list>
<ProgressBar
android:layout_width="match_parent"
android:layout_height="10dp"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="30"
android:progressDrawable="@drawable/progress_bar_star_bg"/>
progress_bar_star_bg.xml
文件<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" >
<shape>
<solid android:color="#ffffffff" />
</shape>
</item>
<item android:id="@android:id/progress"
android:drawable="@drawable/star" />
</layer-list>
indeterminateDrawable
属性<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@anim/anim_progress_bar"
android:indeterminateDuration="1000"/>
anim_progress_bar.xml
文件<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/nav_refresh"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%" />
相关文章
Android ProgressBar控件
Android SeekBar控件
Android RatingBar控件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。