本文实例讲述了Android编程ProgressBar自定义样式之动画模式实现方法。分享给大家供大家参考,具体如下:
忘记在哪里看到的那位仁兄写的,就是通过用动画效果来实现的,现在顺便也把他写出来,希望那位仁兄不要见怪。
效果:
和之前的一样,在布局文件中:
1
2
3
4
5
6
|
< ProgressBar android:id = "@+id/progressBar3" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:indeterminate = "false" android:indeterminateDrawable = "@anim/progress_bar_loading" /> |
然后在values下面建一个anim的文件夹,将progressbar_bar_loading文件放进去即可:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<? xml version = "1.0" encoding = "UTF-8" ?> < animation-list xmlns:android = "http://schemas.android.com/apk/res/android" android:oneshot = "false" > < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_01" /> < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_02" /> < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_03" /> < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_04" /> < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_05" /> < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_06" /> < item android:duration = "250" android:drawable = "@drawable/progress_bar_loading_07" /> </ animation-list > |
其中那些都是一张一张图片,就像替换换图片那样。
希望本文所述对大家Android程序设计有所帮助。