2013-03-12 49 views
0

搜索欄:搜索欄拇指不顯示,如果它是一個形狀

<SeekBar 
    android:id="@+id/seekBar" 
    android:layout_width="0dip" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:paddingLeft="20dip" 
    android:paddingRight="20dip" 
    android:progressDrawable="@drawable/bg" 
    android:thumb="@drawable/thumb" 
    android:thumbOffset="0px" /> 

問題:工作,如果拇指繪製它的位圖,但像

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 
    <solid android:color="#ffff0000" /> 
</shape> 

拇指形狀不顯示。

我試過這樣的事情:

Drawable thumb = getResources().getDrawable(R.drawable.thumb); 
thumb.setBounds(0,0,20,20); 
seekBar.setThumb(thumb); 

但還是同樣的問題。 drawable是「there」,它可以被拖動,並且它在正確的位置,但它不可見。任何幫助?提前致謝!

回答

8

嘗試添加尺寸到您的形狀這樣的:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 
    <solid android:color="#ffff0000" /> 
<size 
     android:width="20dp" 
     android:height="20dp" /> 
</shape> 
+0

唉唉:)忘了這一點。謝謝! – Ixx 2013-03-12 22:05:05