Vertical progress bar in android

I want to create a vertical progress bar in android when performing a specific action. Progress must begin with the 1st badge and end with the final sh0wing badge. I can't seem to find a way to do this.

if any organ can help get one foot in the door. I will be very grateful.

+6
source share
3 answers

It’s a little difficult to say what kind of transition you are trying to make between these two images. So, do you want to start with a black and white image, but does it switch from B / W to color with cross fading, or do you slowly want to apply pieces of the color image from bottom to top along the B / W part?

If your last choice, your actual image will consist of two drawings together inside the <layer-list> . One is static and the other is ClipDrawable , which will display part of the color image based on its level value. For example, create an XML file:

Res / extract / 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 Drawable to something like ImageView to display the progress, and change the value using 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 level progress.setImageLevel(500); // -- OR -- progress.getDrawable().setLevel(500); 

Drawing levels are set by default in the range from 0 to 10000 for full disclosure of the image.

NTN

+14
source

you can use LevelListDrawable and set the level using setLevel (int)

http://developer.android.com/reference/android/graphics/drawable/LevelListDrawable.html

You can add continuous frames in the progress bar to the levellistddrawable and continue to increase the level.

0
source

The best way I can come up with is to use the original bitmap as a background, and then draw parts of the finished image above it from the bottom up. Thus, you do not need a bunch of different images - just step by step drawing a finished image. I think it can be done something like this:

 // setup // assuming firstImage is the initial one and secondImage is the final one int totalHeight = firstImage.getHeight(); Canvas canvas = new Canvas(firstImage); ImageView imgView = (ImageView)findViewById(R.id.flame_bar_view); imgView.setImageBitmap(firstBitmap); Rect src = new Rect (0, totalHeight, firstImage.getWidth(), totalHeight); // then on each update void updateFlameBar(float percentage) { int height = (int)(totalHeight * percentage); src.top = totalHeight - height; canvas.drawBitmap(secondImage, src, src, null); } 
0
source

Source: https://habr.com/ru/post/905351/


All Articles