I want to make a vertical progress bar in android while performing a particular action. The progress should start from from 1st icon and end in the final icon sh0wing steady progress. I cant seem to find a way to do it.
if any body can help get one foot in the door . I will be highly obliged.
It's a bit hard to tell the transition you are trying to attempt between those two images. So you want to start with the B/W image, but does it transition from B/W to Color by cross-fading, or do you slowly want to apply pieces of the color image from the bottom up over the B/W piece?
If the latter is your choice, then your actual image will comprise of two drawables together inside a <layer-list>
. One static, and the other representing a ClipDrawable
that will reveal a portion of the color image based on its level value. For example, create an XML file:
res/drawable/progress_background.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap android:src="@drawable/ic_launcher_bw"/>
</item>
<item>
<clip
android:clipOrientation="vertical"
android:gravity="bottom"
android:drawable="@drawable/ic_launcher"/>
</item>
</layer-list>
Then set that Drawable
on something like an ImageView
to display the progress, and change the value with calls to setLevel()
, i.e.
//This is any view subclass that you have chosen to do this
ImageView progress;
progress.setImageResource(R.drawable.progress_background);
//Adjust the progress by adjusting the drawable's level
progress.setImageLevel(500);
// -- OR --
progress.getDrawable().setLevel(500);
Drawable levels are set by default from 0 to 10,000 to represent fully clipped to fully revealed.
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With