I'm using the out of the box android SeekBar component. Below I would like to add the numbers form 1 to 5 showing the progress of the SeekBar. I have problem distributing the numbers correctly on the seek bar.
Just like the image below
For drawing text over the seekbar thumb use this function
public BitmapDrawable writeOnDrawable(int drawableId, String text){
Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setStyle(Style.FILL);
paint.setColor(Color.BLACK);
paint.setTextSize(20);
Canvas canvas = new Canvas(bm);
canvas.drawText(text, 0, bm.getHeight()/2, paint);
return new BitmapDrawable(bm);
}
This function will call as
seekbar.setThumb(writeOnDrawable(R.drawable.thumbimage, mytext)); put thumbimage.png file in res/drawable/ and 'mytext' is the string which you want to write on top of that drawable
For complete conversation see the below link
how to set the seek bar thumb with a layout or with a TextView?
Hope this will be helpful to you.
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