2015-06-14 124 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,不是为了渲染颜色而相乘。