0

i want seekbar in which there should be image and text upon the thumb and while scrolling image and text should be stay upon thumb of seekbar in Android please help me.

shripal
  • 1,222
  • 4
  • 19
  • 40

1 Answers1

0

You can define a new thumb as a Drawable. You can transform any View in a Drawable.

TextView yourView = new TextView(this);
yourView.setText("text");
yourView.setBackgroundResource(R.drawable.background_resource);

// taken from the other ticket
Bitmap snapshot = null;
Drawable drawable = null;
yourView.setDrawingCacheEnabled(true);
yourView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW); //Quality of the snpashot
try {
    snapshot = Bitmap.createBitmap(yourView.getDrawingCache(), sizes and stuff); // You can tell how to crop the snapshot and whatever in this method
    drawable = new BitmapDrawable(snapshot)
} finally {
    yourView.setDrawingCacheEnabled(false);
}

mySeekBar.setThumb(drawable);

I didn't try this code, but the solution should go into this direction.

Then, thumb can be created statically, as a Drawable xml, for example layering different images. Anyway, if you want it to contain a dynamic content you should create it dynamically, so periodically update it. Create a layout with a textview and then use this: Create drawable from layout

Community
  • 1
  • 1
Beppi's
  • 2,089
  • 1
  • 21
  • 38