Progressbar custom progress bar style

Custom progress barProgressbar

1. Create an xml under drawable

<?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>
            <!-- 角球-->
            <corners android:radius="5dip" />
            <!--梯度-->
            <gradient
                android:angle="0"
                android:centerColor="#F0F1F3"
                android:centerY="0.75"
                android:endColor="#F0F1F3"
                android:startColor="#F0F1F3" />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="0"
                    android:centerColor="#80ffb600"
                    android:centerY="0.75"
                    android:endColor="#a0ffcb00"
                    android:startColor="#80ffd300" />
            </shape>
        </clip>
    </item>

    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="0"
                    android:endColor="#4B6BED"
                    android:startColor="#4B6BED" />
            </shape>
        </clip>
    </item>

</layer-list>

2. Where used

 <ProgressBar
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="13dp"
            android:layout_marginTop="21dp"
            android:layout_marginEnd="13dp"
            android:max="100"
            android:progress="50"
            android:progressDrawable="@drawable/progressbar"
            app:layout_constraintTop_toBottomOf="@+id/appCompatTextView13" />

3. Come and show
Insert image description here

Guess you like

Origin blog.csdn.net/jiayuanwai/article/details/130841161