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" |
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" > |
08 | android:indeterminateDrawable = "@drawable/my_progress_indeterminate" |
09 | android:layout_height = "100dp" android:layout_width = "100dp" /> |
出处: http://www.tedz.me/android/custom-indeterminate-progressbar-color/
- Android(安卓)Material Design 组件集合Demo,附源码地址 :CimoGall
- 安卓缓存-LruCache介绍
- android背景图片更换――经典例子
- Android(安卓)thumbnail 缩略图的获取及与原始图片的映射关系
- Android开发本地及网络Mp3音乐播放器(五)实现专辑封面图片
- Android沉浸式状态栏/状态栏设置背景图片/自定义渐变式状态栏
- Android(安卓)ImageView ScaleType
- Android圆形图片控件RoundedImageView
- 图片阴影
随机推荐
-
android 拍照以及压缩处理
-
Android(安卓)基于RecyclerView上下拉刷
-
Android到底那个Acitivity启动
-
Android(安卓)使用RoundedImageView得不
-
Android中不能在子线程中更新View视图的
-
Android(安卓)自定义组件相关
-
Mac下完全卸载干净Android(安卓)Studio的
-
AS插件-Android(安卓)Layout ID Converte
-
Android中Context和Resource之间的关系
-
Android使用代码实现左右半圆的按钮背景