Android: 如何在进度条中结束进度?

Android: How to round off end of progress, in a progress-bar?

如何把进度条的结尾四舍五入。下图中是我目前拥有的。正如您所看到的边界,开始和结束是圆形的。我还想在进展结束的地方结束。我该怎么做?

我的custom_progressbar.xml

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

    <!-- Define the background properties like color etc -->
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="8dp" />
            <solid android:color="@color/progressBarStrokeColor" />
        </shape>
    </item>
    
    <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="8dp" />
                <gradient
                    android:angle="180"
                    android:centerColor="@color/purple_700"
                    android:centerY="1.0"
                    android:endColor="#000000"
                    android:startColor="@color/red" />
            </shape>
        </clip>
    </item>
</layer-list>

请试试这个我将 <clip/> 标签更改为 <scale/> 并将 scaleWidth 设置为 100%: consult the official documentation

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

    <!-- Define the background properties like color etc -->
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="8dp" />
            <solid android:color="@android:color/darker_gray" />
        </shape>
    </item>

    <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <scale android:scaleWidth="100%">
            <shape>

                <corners android:radius="8dp" />
                <gradient

                    android:angle="180"
                    android:centerColor="@color/purple_700"
                    android:centerY="1.0"
                    android:endColor="#000000"
                    android:startColor="@android:color/holo_red_light" />
            </shape>
        </scale>
    </item>
</layer-list>

这是输出: