setProgressDrawable填充整个seekBar

KrL*_*ler 6 android progress fill seekbar progress-bar

正如我在标题中所说,当我使用setProgressDrawable时,它会填满整个SeekBar:如果进度为34%,则进度显示为100%但拇指显示正确的百分比34%.我不知道可能是什么问题......

   done.setProgressDrawable(getResources().getDrawable(R.drawable.seekbar_progress));
   done.setThumb(getResources().getDrawable(R.drawable.seekbar_thumb));
Run Code Online (Sandbox Code Playgroud)

seekbar_progress.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:width="15dp"    android:color="#52a8ec"/>
Run Code Online (Sandbox Code Playgroud)

seekbar_thumb.xml

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
<gradient android:startColor="#ffffffff" android:endColor="#ff585858" android:angle="270"/>
<size android:height="17dp" android:width="5dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

任何的想法?

先感谢您!

小智 8

尝试将填充形状放在剪辑标签内

<clip>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:width="15dp"    android:color="#52a8ec"/>
</clip>
Run Code Online (Sandbox Code Playgroud)


Mil*_*sic 1

我遇到了与您相同的情况,并通过使用图层列表 XML 文件实现进度来解决该问题。在这里查看我的答案。