我使用的是開箱即用的android SeekBar組件。下面我想添加數字形式1到5,顯示SeekBar的進度。我有問題在尋找欄上正確分配數字。如何在Android SeekBar上添加數字縮放比例
就像下面
我使用的是開箱即用的android SeekBar組件。下面我想添加數字形式1到5,顯示SeekBar的進度。我有問題在尋找欄上正確分配數字。如何在Android SeekBar上添加數字縮放比例
就像下面
圖像繪製文字在搜索條拇指使用此功能
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文件是要上的是繪製
有關完整的談話頂部寫入字符串見下面的鏈接
how to set the seek bar thumb with a layout or with a TextView?
希望這會對你有所幫助。
這不會回答問題。 – Ixx 2014-07-22 12:27:24
我認爲你需要這樣的東西http://www.techrepublic.com/blog/app-builder/androids-seekbar-your-way/943 – Pragnani 2013-03-12 12:03:57
我只需要在佈局中分配數字, t需要一個監聽器,滑塊停在我想要的地方,我只需要在它停止的地方添加一個數字 – user1796624 2013-03-12 12:06:20
我認爲你需要用seek bar和TextView創建一個自定義視圖來實現你想要的 – Pragnani 2013-03-12 12:07:55