Rounded gradient in custom Progress Bar

我们两清 提交于 2019-12-05 19:42:55
AnZ

Seems like I found a workaround thanks for giving right direction to search to @krislarson and this post

The resulting code: pb_shape.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">

    <shape android:shape="rectangle">

        <corners android:radius="12dip" />

        <stroke
            android:width="1dip"
            android:color="@color/primary_white" />

        <gradient
            android:angle="270"
            android:centerColor="@color/primary_black"
            android:centerY="0.5"
            android:endColor="@color/primary_black"
            android:gradientRadius="12dip"
            android:startColor="@color/primary_black" />
    </shape>
</item>

<item android:id="@android:id/progress">
    <scale
        android:drawable="@drawable/pb_custom_progress"
        android:scaleWidth="98%" />
</item>
</layer-list>

pb_custom_progress.xml here goes the magic:

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

<!--make it rounded-->
<corners
    android:radius="20dp"
    android:topLeftRadius="20dp"
    android:topRightRadius="20dp" />

<gradient
    android:angle="0"
    android:endColor="@color/primary_teal"
    android:startColor="@color/primary_blue_dark" />

<!--create invisible stroke for padding-->
<stroke
    android:width="6dip"
    android:color="@android:color/transparent"/>

</shape>

result:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!