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

简单解决方案:

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

view source print ?
01 <ProgressBar style="@android:style/Widget.ProgressBar.Inverse"/>
02 <ProgressBar style="@android:style/Widget.ProgressBar.Large.Inverse"/>
03 <ProgressBar style="@android:style/Widget.ProgressBar.Small.Inverse"/>

转自: How to change android indeterminate ProgressBar color

高级方案: 自定义颜色

步骤:

  • 用任何图片编辑器编辑一张ProgressBar需要的图片
  • 用这张图片创建一个animation drawable
view source print ?
01 <?xml version="1.0" encoding="utf-8"?>
02 <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
03 android:drawable="@drawable/image_for_rotation"
04 android:pivotX="50%"
05 android:pivotY="50%" />

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

  • 给ProgressBar widget设定android:indeterminateDrawable
view source print ?
01 <?xml version="1.0" encoding="utf-8"?>
02 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
03 android:orientation="vertical"
04 android:layout_width="fill_parent"
05 android:layout_height="fill_parent"
06 android:gravity="center">
07 <ProgressBar
08 android:indeterminateDrawable="@drawable/my_progress_indeterminate"
09 android:layout_height="100dp" android:layout_width="100dp"/>
10 </LinearLayout>
出处: http://www.tedz.me/android/custom-indeterminate-progressbar-color/

更多相关文章

  1. Android(安卓)Material Design 组件集合Demo,附源码地址 :CimoGall
  2. 安卓缓存-LruCache介绍
  3. android背景图片更换――经典例子
  4. Android(安卓)thumbnail 缩略图的获取及与原始图片的映射关系
  5. Android开发本地及网络Mp3音乐播放器(五)实现专辑封面图片
  6. Android沉浸式状态栏/状态栏设置背景图片/自定义渐变式状态栏
  7. Android(安卓)ImageView ScaleType
  8. Android圆形图片控件RoundedImageView
  9. 图片阴影

随机推荐

  1. android 拍照以及压缩处理
  2. Android(安卓)基于RecyclerView上下拉刷
  3. Android到底那个Acitivity启动
  4. Android(安卓)使用RoundedImageView得不
  5. Android中不能在子线程中更新View视图的
  6. Android(安卓)自定义组件相关
  7. Mac下完全卸载干净Android(安卓)Studio的
  8. AS插件-Android(安卓)Layout ID Converte
  9. Android中Context和Resource之间的关系
  10. Android使用代码实现左右半圆的按钮背景