Android 自定義顏色ProgressBar

創建一個drawable

shape_progress_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360">
    <shape
        android:innerRadiusRatio="3"
        android:shape="ring"
        android:thicknessRatio="18"
        android:useLevel="false">
        <gradient
            android:centerColor="#ff538c"
            android:centerY="0.50"
            android:endColor="#fff"
            android:startColor="#ef004f"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</animated-rotate>

在layout中使用ProgressBar

  <ProgressBar
                style="@android:style/Widget.ProgressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:indeterminateDrawable="@drawable/shape_progress_bar" />

效果如下


12350543-b1d02b3411b461ba.png
image.png
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章