Android水平進(jìn)度條顏色和樣式

繼承關(guān)系


java.lang.Object

??? ?android.view.View

??????? ?android.widget.ProgressBar

直接子類:AbsSeekBar extends ProgressBar;間接子類:RatingBar,?SeekBar。

ProgressBar


ProgressBar有兩種展示形式:

(1)android:progressBarStyle:默認(rèn)進(jìn)度條樣式,不確定模式;(分大小)

(2)android:progressBarStyleHorizontal:水平進(jìn)度條樣式。

改變水平ProgressBar示例


1、progress布局:

<ProgressBar

android:id="@+id/update_progress"

style="?android:attr/progressBarStyleHorizontal"

android:layout_width="fill_parent"

android:layout_height="8dp"

android:layout_centerHorizontal="true"

android:progressDrawable="@drawable/progressbar"/>

為改變進(jìn)度條樣式和顏色,需要復(fù)寫Android系統(tǒng)自帶的樣式并引用:android:progressDrawable="@drawable/progressbar";

2、下面為drawable下progressbar.xml:

<?xml version="1.0"encoding="utf-8"?>

<layer-listxmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@android:id/background">

<shape>

<cornersandroid:radius="5dip"/>

<gradient

android:angle="0"

android:centerColor="#ff5a5d5a"

android:centerY="0.75"

android:endColor="#777777"

android:startColor="#777777"/>

</shape>
</item>

<!--類似于視頻緩沖未播放狀態(tài)時的進(jìn)度顏色-->

<item android:id="@android:id/secondaryProgress">

<clip>

<shape>

<cornersandroid:radius="5dip"/>

<gradient

android:angle="0"

android:centerColor="##606360"

android:centerY="0.75"

android:endColor="#606360"

android:startColor="#606360"/>

</shape>

</clip>

</item>

<item android:id="@android:id/progress">

<clip>

<shape>

<cornersandroid:radius="5dip"/>

<gradient

android:angle="0"

android:endColor="#00ff00"

android:startColor="#ff0000"/>

</shape>

</clip>

</item>

</layer-list>

效果圖







最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容