Android seekbar set custom style using nine-patch images

杀马特。学长 韩版系。学妹 提交于 2019-11-29 04:10:01

e_x_p's version works just fine but the even simpler version is

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

    <item android:id="@android:id/background">
        <nine-patch android:src="@drawable/progressbar_bg" android:dither="true"/>
    </item>
    <item android:id="@android:id/progress">
        <clip xmlns:android="http://schemas.android.com/apk/res/android"
            android:clipOrientation="horizontal"
            android:gravity="left">
            <nine-patch android:src="@drawable/progressbar_status" android:dither="true"/>
        </clip>
    </item>

</layer-list>

I solved this problem using a ClipDrawable. This is what worked for me:

Set @drawable/search_progress_drawable as the progressDrawable.

search_progress_drawable.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background" android:drawable="@drawable/search_progress"></item>
    <item android:id="@android:id/progress" android:drawable="@drawable/search_progress_clip"></item>
</layer-list>

search_progress_clip.xml:

<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/search_progress_bar"
    android:clipOrientation="horizontal"
    android:gravity="left">
</clip>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!