How to make a progress bar use an image to show progress instead of using a color in Android
I have a logo image that I would like to use in my progress bar. Each time an image is downloaded, my progress bar creeps up using a blue bar. However, I would prefer that it slowly display my logo image, one bit at a time. I tried:
android:progressDrawable="@drawable/logo"
but that just set the entire progress bar immediately to my image. I also tried setting it dynamically with:
progressBar.setProgressDrawable(getResources()...etc)
but this just left me with no view and a bl开发者_如何学Goack empty space.
Can be done?
Create a ClipDrawable and set your progressDrawable in XML to point to that ClipDrawable XML which looks something like this:
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/logo"
android:clipOrientation="horizontal"
android:gravity="left" />
</clip>
Then in the onProgress just call yourDrawable.setLevel(progressAmount)
Try to use:
progressBar.setIndeterminateDrawable(getResources()...etc)
精彩评论