Android 如何在seekbar的拇指上绘制图像和文本。而滑动图像和值应该用seekbar的拇指附着

Android 如何在seekbar的拇指上绘制图像和文本。而滑动图像和值应该用seekbar的拇指附着,android,Android,我想要seekbar,其中拇指上应该有图像和文本,而在Android中滚动图像和文本时,seekbar的拇指上应该有图像和文本,请帮助我。您可以将新拇指定义为可绘制。可以在可绘制图形中变换任何视图 TextView yourView = new TextView(this); yourView.setText("text"); yourView.setBackgroundResource(R.drawable.background_resource); // taken from the ot

我想要seekbar,其中拇指上应该有图像和文本,而在Android中滚动图像和文本时,seekbar的拇指上应该有图像和文本,请帮助我。

您可以将新拇指定义为可绘制。可以在可绘制图形中变换任何视图

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);
我没有尝试这段代码,但解决方案应该朝这个方向发展

然后,可以静态地创建thumb,作为可绘制的xml,例如分层不同的图像。无论如何,如果你想让它包含一个动态内容,你应该动态创建它,所以定期更新它。
创建一个带有文本视图的布局,然后使用以下内容:

谢谢你的回复…但如果可能的话,我会得到它,然后请给我整个班级