Android編程實(shí)現(xiàn)自定義ProgressBar樣式示例(背景色及一級(jí)、二級(jí)進(jìn)度條顏色)
本文實(shí)例講述了Android編程實(shí)現(xiàn)自定義ProgressBar樣式。分享給大家供大家參考,具體如下:
效果圖如下,本例中設(shè)置了第一級(jí)進(jìn)度條和第二級(jí)進(jìn)度條。

樣式資源:progressbar_bg.xml,放在drawable文件夾下:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--3個(gè)層的順序即為顯示時(shí)的疊加順序-->
<!--背景色-->
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<solid android:color="#CCCCCC" />
</shape>
</item>
<!--二級(jí)進(jìn)度條的顏色-->
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#88F56100" />
</shape>
</clip>
</item>
<!--一級(jí)進(jìn)度條的顏色,也可以直接替換成圖片-->
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#F56100" />
</shape>
</clip>
</item>
</layer-list>
布局代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:minHeight="20dp"
android:padding="10dp"
android:progressDrawable="@drawable/progressbar_bg" />
</LinearLayout>
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android布局layout技巧總結(jié)》、《Android視圖View技巧總結(jié)》、《Android開發(fā)動(dòng)畫技巧匯總》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- Android編程之ProgressBar圓形進(jìn)度條顏色設(shè)置方法
- android ListView和ProgressBar(進(jìn)度條控件)的使用方法
- Android實(shí)現(xiàn)進(jìn)度條(ProgressBar)的功能與用法
- Android三種方式實(shí)現(xiàn)ProgressBar自定義圓形進(jìn)度條
- Android ProgressBar進(jìn)度條使用詳解
- Android ProgressBar進(jìn)度條和ProgressDialog進(jìn)度框的展示DEMO
- Android進(jìn)度條控件progressbar使用方法詳解
- Android ProgressBar直線進(jìn)度條的實(shí)例代碼
- Android progressbar實(shí)現(xiàn)帶底部指示器和文字的進(jìn)度條
- android實(shí)現(xiàn)簡(jiǎn)單進(jìn)度條ProgressBar效果
相關(guān)文章
Android實(shí)現(xiàn)登錄注冊(cè)功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)登錄注冊(cè)功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04
Flutter彈性布局Flex水平排列Row垂直排列Column使用示例
這篇文章主要為大家介紹了Flutter彈性布局Flex水平排列Row垂直排列Column使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
Android模擬開關(guān)按鈕點(diǎn)擊打開動(dòng)畫(屬性動(dòng)畫之平移動(dòng)畫)
這篇文章主要介紹了Android模擬開關(guān)按鈕點(diǎn)擊打開動(dòng)畫(屬性動(dòng)畫之平移動(dòng)畫)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09
用于cocos2d-x引擎(ndk)中為android項(xiàng)目生成編譯文件列表
在android的ndk項(xiàng)目中,添加很多源文件之后總要手動(dòng)編寫makefile來添加所有的源文件, 很麻煩,所以寫了一個(gè)自動(dòng)生成編譯源文件列表的小工具2014-05-05
Android自定義ViewGroup之CustomGridLayout(一)
這篇文章主要為大家詳細(xì)介紹了Android自定義ViewGroup之CustomGridLayout的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-09-09
Android?webView加載數(shù)據(jù)時(shí)內(nèi)存溢出問題及解決
這篇文章主要介紹了Android?webView加載數(shù)據(jù)時(shí)內(nèi)存溢出問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12

