2015-06-14 100 views
0

我想1)將拇指的顏色更改爲我在代碼中具有的顏色int。 2)確保有進步和自定義android seekbar thumb

Drawable thumb = getResources().getDrawable(R.drawable.thumb, getContext().getTheme()); 
// seekbarColorStr can be #0011FF, etc 
thumb.setColorFilter(Color.parseColor(seekbarColorStr), PorterDuff.Mode.MULTIPLY); 
seekBar.setThumb(thumb); 

我thumb.xml拇指之間沒有空格:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval"> 

<size 
    android:height="20dp" 
    android:width="20dp" /> 

</shape> 

我在How to change colour of the thumb in seekbar?

拇指改變顏色的想法呈現黑色,並且由於它是圓形的,而進度是矩形的,所以兩者之間有空白。

+1

嘗試設置['seekBar.setSplitTrack(false);'](https://developer.android.com/reference/android/widget/AbsSeekBar.html#setSplitTrack(boolean))。 –

+0

@EugenPechanec謝謝,但只存在於API 21及以上。那麼棒棒糖呢? – MarcusH

回答

0

正確的PorterDuff模式是SRC_IN,不是爲了渲染顏色而相乘。