问题描述:

Seekbar:

<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" />

Problem: Works if thumb drawable it's a bitmap, but with a shape like

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle" >

<solid android:color="#ffff0000" />

</shape>

The thumb doesn't show.

I tried with things like this:

Drawable thumb = getResources().getDrawable(R.drawable.thumb);

thumb.setBounds(0,0,20,20);

seekBar.setThumb(thumb);

But still the same problem. The drawable is "there", it can be dragged, and it's in the correct place, but it's not visible. Any help? Thanks in advance!

网友答案:

Try add size to your shape this:

    <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>
相关阅读:
Top