Realize different ProgressBar through drawable

ProgressBar is a common view in development. There are many requests for horizontal progress bars. Match the style of the UI. There will be different colors.
There are also many custom ones online. If it is just to modify the color, it is unnecessary. Available in the following ways:

Create a file in drawable. (If there are students who don’t know where the drawable is. Please give up the development.) The name is optional.

<?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>
            <solid android:color="#00000000" />
            <corners android:radius="12dp" />
        </shape>
    </item>
    <!--    缓冲进度条的背景色-->
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <solid android:color="#00000000" />
            </shape>
        </clip>
    </item>
    <!--  进度条的颜色-->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <solid android:color="#34FFE7" />
            </shape>
        </clip>
    </item>
</layer-list>

Here is the documentation on customizing the color of the progress bar. The method of use is to use the progressDrawable attribute in the ProgressBar, as follows:

android:progressDrawable="@drawable/xxxx"

That's it.
Good life is safe! ! ! !
NED

Guess you like

Origin blog.csdn.net/lixinxiaos/article/details/128456811