Android UI之ProgressBar(进度条)


进度条是一个很实用的组件,一般用来显示用户某个耗时操作的进度百分比,首先来看一下Android支持的几种风格的进度条:

style="@android:style/Widget.ProgressBar.Inverse"   普通大小进度条

style="@android:style/Widget.ProgressBar.Large" 大进度条

style="@android:style/Widget.ProgressBar.Large.Inverse" 大进度条

style="@android:style/Widget.ProgressBar.Small"  小进度条
style="@android:style/Widget.ProgressBar.Small.Inverse"  小进度条

style="@android:style/Widget.ProgressBar.Horizontal"水平进度条

在样式文件中分别添加这六个不同样式的进度条,看看在模拟器上的效果

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <TextView  
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="wrap_content"  
  10.         android:text="进度条演示" />  
  11.   
  12.     <ProgressBar   
  13.         android:layout_width="wrap_content"  
  14.         android:layout_height="wrap_content"  
  15.         android:max="1000"  
  16.         android:progress="100"  
  17.         android:id="@+id/progressbar1"  
  18.         />  
  19.       
  20.     <ProgressBar   
  21.         style="@android:style/Widget.ProgressBar.Inverse"  
  22.         android:layout_width="wrap_content"  
  23.         android:layout_height="wrap_content"  
  24.         android:max="100"  
  25.         android:progress="20"  
  26.         />  
  27.         <ProgressBar   
  28.         style="@android:style/Widget.ProgressBar.Large"  
  29.         android:layout_width="wrap_content"  
  30.         android:layout_height="wrap_content"  
  31.         android:max="100"  
  32.         android:progress="20"  
  33.         />  
  34.      <ProgressBar   
  35.         style="@android:style/Widget.ProgressBar.Large.Inverse"  
  36.         android:layout_width="wrap_content"  
  37.         android:layout_height="wrap_content"  
  38.         android:max="100"  
  39.         android:progress="20"  
  40.         />  
  41.     <ProgressBar   
  42.         style="@android:style/Widget.ProgressBar.Small"  
  43.         android:layout_width="wrap_content"  
  44.         android:layout_height="wrap_content"  
  45.         android:max="100"  
  46.         android:progress="20"  
  47.         />  
  48.     <ProgressBar   
  49.         style="@android:style/Widget.ProgressBar.Small.Inverse"  
  50.         android:layout_width="wrap_content"  
  51.         android:layout_height="wrap_content"  
  52.         android:max="100"  
  53.         android:progress="20"  
  54.         />      
  55.     <ProgressBar   
  56.         style="@android:style/Widget.ProgressBar.Horizontal"  
  57.         android:layout_marginTop="30dp"  
  58.         android:layout_width="fill_parent"  
  59.         android:layout_height="wrap_content"  
  60.         android:max="1000"  
  61.         android:progress="500"  
  62.         android:secondaryProgress="300"  
  63.         android:id="@+id/progressbar2"  
  64.         />  
  65. </LinearLayout>  
在模拟器上的效果:
  • 1
  • 2
  • 下一页

相关内容