如何將ProgressBar設(shè)置成橫向進(jìn)度條并修改進(jìn)度條顏色?文章來源:http://www.zghlxwxcb.cn/news/detail-535001.html
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="4dp"
app:layout_constraintTop_toBottomOf="@id/title"
android:layout_marginTop="15dp"
android:max="100"
android:progress="10"
android:progressDrawable="@drawable/progress_style_h_scene"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"/>
- 設(shè)置為橫向進(jìn)度條:
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
- 設(shè)置進(jìn)度條顏色:
自定一個(gè)文件名為progress_style_h_scene的drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--設(shè)置progress背景顏色-->
<item android:id="@android:id/background">
<shape>
<corners android:radius="8dp"/>
<solid android:color="@color/color_999999" />
</shape>
</item>
<!--設(shè)置progress進(jìn)度條顏色-->
<item android:id="@android:id/progress">
<clip android:clipOrientation="horizontal">
<shape>
<corners android:radius="8dp"/>
<solid android:color="@color/color_FF8F6C" />
</shape>
</clip>
</item>
</layer-list>
將自定義的drawable設(shè)置到ProgressBar的android:progressDrawable屬性中文章來源地址http://www.zghlxwxcb.cn/news/detail-535001.html
android:progressDrawable="@drawable/progress_style_h_scene"
到了這里,關(guān)于Android ProgressBar設(shè)置成橫向進(jìn)度條并自定義進(jìn)度條顏色的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!