Hyeyeon blog

[Android] Horizontal ProgressBar 색상 변경 본문

개발/Android

[Android] Horizontal ProgressBar 색상 변경

Hyeyeon.P 2019. 11. 4. 17:22
반응형

1. progressDrawable 생성 (drawable/progress.xml)

  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="8dp"/>
            <solid android:color="@color/bgColor"/>
        </shape>
    </item>

    <item android:id="@android:id/progress"
        android:top="1dp"
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp">

        <scale android:scaleWidth="100%">
            <shape>
                <corners android:radius="8dp"/>
                <solid android:color="@color/barColor"/>
            </shape>
        </scale>
    </item>
</layer-list>

2. 적용

- 가로형 프로그레스바 Style과 함께 progressDrawable 적용

<ProgressBar
    ...
    style="?android:attr/progressBarStyleHorizontal"
    android:progressDrawable="@drawable/progressbar" />

728x90
Comments