android-square-progressbar v.1.4.1

android-square-progressbar v.1.4.1

I just found time to add a very interesting feature to the android-square-progressbar library. You now can set a in-code generated bitmap as the image. This also opens the door to display Text, where the progressbar goes around. This can’t replace a normal TextView, but its a start.

Extended Example

An example of such a usage would be the following. Maybe you want to display a dynamic text like a countdown or something like that. You can do this with a bitmap, that you can redraw (but if you have loads and loads of redraws, don’t do this!). I have added the following example to the wiki but I will repeat it here with a bit more text.

First of all, you create a new Bitmap in your code. I’ve set the height and the width of it to 250 and added this ARGB_8888 configuration, which makes it opaque.

Bitmap bmp = Bitmap.createBitmap(250, 250, Bitmap.Config.ARGB_8888);

I’m then creating a new canvas for the Bitmap. After that I’m configuring the paint for the text I want to write.

Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setTextSize(60);
paint.setTextAlign(Paint.Align.CENTER);
paint.setColor(Color.parseColor("#D11111"));
canvas.drawText("Crimbo!",125,155, paint);

On the last line, I’m actually writing the text onto the canvas. Afterwards my drawing is finished and I now can use the new method to set the Bitmap to the ImageView.

squareProgressBar.setImageBitmap(bmp);

If you then add the rest of the normal code that the library needs (see the wiki) the result is the following:

crimbo

You can find the GitHub Repository here: https://github.com/mrwonderman/android-square-progressbar

Yannick Signer