Android Seekbar和InsertDrawable可查看进度

Android Seekbar和InsertDrawable可查看进度,android,xml,seekbar,Android,Xml,Seekbar,嗨,我试着定制一个seekbar 我的问题是: main.xml ... <SeekBar android:id="@+id/seekBar1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true"

嗨,我试着定制一个seekbar

我的问题是:

main.xml

   ...
    <SeekBar android:id="@+id/seekBar1" 
                android:layout_width="match_parent" 
                android:layout_height="wrap_content" 
                android:layout_alignParentLeft="true"
                android:thumb="@drawable/seekbarthumb"
                android:progressDrawable="@drawable/sb2"
                android:minHeight="45dip"
                android:maxHeight="45dip"
            ></SeekBar>
    ...
。。。
...
@drawable中的sb2.xml

<layer-list  xmlns:android="http://schemas.android.com/apk/res/android">   
<item android:id="@android:id/background" 
    android:drawable="@drawable/seekbarbg">
</item>
<item android:id="@android:id/progress"
    android:drawable="@drawable/sb_progress">
</item>
</layer-list>

一切正常,但sb_进度处于错误位置

所以我有两个解决方案。更改sb_进度的位置,或使用Photoshop编辑sb_进度,并添加透明像素以修复它

通过尝试改变位置的好方法,出现了一些问题:

我在sb2.xml中添加了一些行

<layer-list  xmlns:android="http://schemas.android.com/apk/res/android">   
<item android:id="@android:id/background" 
    android:drawable="@drawable/seekbarbg">
</item>
<item android:id="@android:id/progress" >
    <inset
    android:drawable="@drawable/sb_progress" 
    android:insetTop="11dip"
    android:insetBottom="11dip"
    android:insetLeft="11dip">
    </inset>
</item>
</layer-list>  

我添加了元素,但结果是suxx。位置是正确的,但进度不再是动画。sb_progress.png始终是全画的,不要停在拇指上

我需要帮助!这是一个Bug,我需要添加透明像素吗?不是吗

可插入绘图的一个子类。为什么seekbar不再适用于不可插入的绘图

java.lang.Object ↳ android.graphics.drawable.drawable
↳ android.graphics.drawable.InsertDrawable

我知道这是一个老问题,但如果有人通过搜索引擎找到了这个问题(就像我一样),你只需要在drawable和inset中添加一个“剪辑”

<item android:id="@android:id/progress" >
    <clip>
    <inset
        android:insetRight="11dp"
        android:insetLeft="11dp">
        <shape>
             <solid android:color="#343434"/>
        </shape>
    </inset>
    </clip>
</item>