ProgressBar的Indeterminate属性

Indeterminate ProgressBar默认是白色的,如果容器的背景也是白色的,这样就根本看不到Progressbar.

简单解决方案:

用style属性设定反转的颜色.

 1 <ProgressBar style="@android:style/Widget.ProgressBar.Inverse"/>

2  <ProgressBar style="@android:style/Widget.ProgressBar.Large.Inverse"/>

3 <ProgressBar style="@android:style/Widget.ProgressBar.Small.Inverse"/> 

 

高级方案: 自定义颜色

步骤:

  • 用任何图片编辑器编辑一张ProgressBar需要的图片
  • 用这张图片创建一个animation drawable
1 <?xml version="1.0" encoding="utf-8"?>
2      <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
3      android:drawable="@drawable/image_for_rotation"
4      android:pivotX="50%"
5      android:pivotY="50%" />

 

 

          @drawable/image_for_rotation 就是那张做好的图片

  • 给ProgressBar widget设定android:indeterminateDrawable

 

 1 <?xml version="1.0" encoding="utf-8"?>    
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3      android:orientation="vertical"
 4      android:layout_width="fill_parent"
 5     android:layout_height="fill_parent"
 6     android:gravity="center">
 7     <ProgressBar
 8     android:indeterminateDrawable="@drawable/my_progress_indeterminate"
 9 android:layout_height="100dp" android:layout_width="100dp"/>
10     </LinearLayout>

 

posted on 2016-03-18 13:37  oooo呼呼  阅读(1967)  评论(0编辑  收藏  举报