如何增加Android上的搜索栏数量规模 [英] How to add number scale on android SeekBar
问题描述
我使用的开箱即用的Android SeekBar组件的。下面我想数字表单中添加1〜5显示了搜索栏的进度。我有问题正确地分发搜索栏上的数字。
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.
就像下面
推荐答案
有关绘制文本在搜索栏拇指使用此功能。
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);
}
此功能会调用为
seekbar.setThumb(writeOnDrawable(R.drawable.thumbimage,MYTEXT));
放在RES /绘制/和'MYTEXT'thumbimage.png文件要上绘上书写字符串
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
<一个href=\"http://stackoverflow.com/questions/12369519/how-to-set-the-seek-bar-thumb-with-a-layout-or-with-a-textview\">how设置搜索栏大拇指布局或一个TextView?
希望这对您有所帮助。
这篇关于如何增加Android上的搜索栏数量规模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!