http://blog.csdn.net/ywtcy/article/details/7878289
This time to do the project, product requirements, progress bar to do a fluorescent effect, similar to the Android4.0 browser in the same way as the progress bar. At first, Miss Bai's elder sister, thought it was to use sharp files or canvas directly drawn out. Later rage, the System browser APK package to untie, the pit dad is, The fluorescence effect of the progress bar is actually a. 9 of the picture, suddenly, ah, but, Google still strong, his progress bar is not ProgressBar, but rewrite ImageView, of course, this is not in today's discussion scope, hehe, interested students can go to see the system browser source code.
This is the effect of the browser loading in Android 4.0, the progress bar, very conspicuous to say ~ ~
And the truth is an ingenious one. 9 Pictures: Progress.9.png (I have to praise the. 9 Picture in Android (Nine-patch), really convenient)
Of course it's easy to use, look at the code:
/res/layout/activity_main.xml
[HTML]View Plaincopy
- < span class= "tag" style= "margin:0px; padding:0px; Border:none; Color:rgb (153,51,0); Background-color:inherit; Font-weight:bold ">< progressbar &NBSP;&NBSP;
- android:id = " @+id/pb " &NBSP;&NBSP;
- style = " android:attr/progressbarstylehorizontal " &NBSP;&NBSP;
- android:layout_width = " fill_parent " &NBSP;&NBSP;
- android:layout_height = " wrap_content " &NBSP;&NBSP;
- android:layout_below = " @id/tv " &NBSP;&NBSP;
- android:progressdrawable="@drawable/progress_drawable" />
/res/drawable/progress_drawable.xml
[HTML]View Plaincopy
- <?XML version="1.0" encoding="Utf-8"?>
- <layer-list xmlns:android="Http://schemas.android.com/apk/res/android" >
- <Item Android:id="@android: Id/progress">
- <Clip android:drawable="@drawable/progress" />
- </ item >
-
- </ layer-list >
And the final effect is this.
However, the actual experience seems a little less perfect, but in theory should be such, hehe, if there are mistakes, but also hope you crossing criticism!
There is also a problem is that the update of the progress bar is a jump, not very smooth, do not know whether to add an animation effect to make progress bar update more Smooth a little, have similar experience of the classmate also hope to support a recruit ah, thank you!
Android ProgressBar progress bar fluorescence effect