Android自定義水平進(jìn)度條的圓角進(jìn)度
平時(shí)項(xiàng)目中經(jīng)常用到自定義進(jìn)度條樣式,我們一般實(shí)現(xiàn)的也是下面的第一種,至于第二種的圓角進(jìn)度,網(wǎng)上介紹的資料也不是很多,這里一起展示一下這兩種的實(shí)現(xiàn)。

下面開始看代碼,先從主界面布局開始看起:
<ProgressBar style="@android:style/Widget.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="20dp" android:layout_margin="10dp" android:max="100" android:progress="20" android:progressDrawable="@drawable/layer_list_progress_drawable_1" /> <ProgressBar style="@android:style/Widget.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="20dp" android:layout_margin="10dp" android:max="100" android:progress="20" android:progressDrawable="@drawable/layer_list_progress_drawable" />
兩個(gè)進(jìn)度條布局,然后是不同的progressDrawable布局:
layer_list_progress_drawable_1.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/shape_progressbar_bg" /> <item android:id="@android:id/progress"> <clip android:drawable="@drawable/shape_progressbar_progress" /> </item> </layer-list>
layer_list_progress_drawable.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/shape_progressbar_bg" /> <item android:id="@android:id/progress"> <scale android:drawable="@drawable/shape_progressbar_progress" android:scaleWidth="100%" /> </item> </layer-list>
從上面兩布局文件可以看出,布局文件基本也是相同的,唯一的區(qū)別就是item progress 的屬性值。
item background也可以直接在ProgressBar配置文件設(shè)置,
如果在layer-list里面進(jìn)行設(shè)置的話,也是要注意item的添加順序。
下面是背景,和進(jìn)度文件:
shape_progressbar_bg.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="10dp" /> <solid android:color="#e2e2e2" /> </shape> shape_progressbar_progress.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="10dp" /> <solid android:color="#f25252" /> </shape>
這兩個(gè)基本也是一樣的。
進(jìn)度條的圓角進(jìn)度也就這是這樣,如果對(duì)配置文件的屬性不明白,請(qǐng)自行Google。
點(diǎn)擊下載:http://xiazai.jb51.net/201608/yuanma/andrioid-progress(jb51.net).rar
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android 七種進(jìn)度條的樣式
- Android中實(shí)現(xiàn)Webview頂部帶進(jìn)度條的方法
- android自定義進(jìn)度條漸變色View的實(shí)例代碼
- Android文件下載進(jìn)度條的實(shí)現(xiàn)代碼
- android ListView和ProgressBar(進(jìn)度條控件)的使用方法
- Android中自定義進(jìn)度條詳解
- Android編程之ProgressBar圓形進(jìn)度條顏色設(shè)置方法
- android自定義進(jìn)度條漸變圓形
- Android帶進(jìn)度的圓形進(jìn)度條
- Android條紋進(jìn)度條的實(shí)現(xiàn)(調(diào)整view寬度仿進(jìn)度條)
相關(guān)文章
Android開發(fā)之自定義view實(shí)現(xiàn)通訊錄列表A~Z字母提示效果【附demo源碼下載】
這篇文章主要介紹了Android開發(fā)之自定義view實(shí)現(xiàn)通訊錄列表A~Z字母提示效果,結(jié)合完整實(shí)例形式分析了Android獲取通訊錄列表及采用自定義view排列顯示的相關(guān)操作技巧,需要的朋友可以參考下2017-07-07
Android畢業(yè)設(shè)計(jì)備忘錄APP
這篇文章主要介紹了一個(gè)Android畢業(yè)設(shè)計(jì)備忘錄APP,它很小,但是功能很全,可實(shí)現(xiàn)添加、刪除、修改、查看的功能,使用Java語言開發(fā),風(fēng)格簡練2021-08-08
Android Studio 3.0中mipmap-anydpi-v26是什么東東
在Android Studio 3.0中一旦我們創(chuàng)建了一個(gè)項(xiàng)目,一個(gè)名為mipmap-anydpi-v26自動(dòng)創(chuàng)建的文件夾在res文件夾下。它究竟能干什么?為什么我們需要這個(gè)?我們在開發(fā)時(shí)該如何利用它,下面通過本文給大家介紹下2017-12-12
Android編程自定義AlertDialog樣式的方法詳解
這篇文章主要介紹了Android編程自定義AlertDialog樣式的方法,結(jié)合實(shí)例形式詳細(xì)分析了Android自定義AlertDialog樣式的具體布局與功能實(shí)現(xiàn)相關(guān)操作技巧,需要的朋友可以參考下2018-02-02
Android如何實(shí)現(xiàn)掃描和生成二維碼
這篇文章主要為大家詳細(xì)介紹了Android如何實(shí)現(xiàn)掃描和生成二維碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05
Android studio報(bào)錯(cuò):The emulator process for AVD (xxx) was kill
這篇文章主要介紹了Android studio報(bào)錯(cuò):The emulator process for AVD (xxx) was killed,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
詳細(xì)解讀Android系統(tǒng)中的application標(biāo)簽
這篇文章主要介紹了Android系統(tǒng)中的application標(biāo)簽,以application來聲明App是Android入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2016-04-04
在Android里完美實(shí)現(xiàn)基站和WIFI定位
眾所周知的,在OPhone和大部分國產(chǎn)的Android定制機(jī)里不支持最簡單實(shí)用的基站和WIFI定位,只能使用速度慢而耗電的GPS定位,但OPhone和華為/中興生產(chǎn)的一些Android定制機(jī)卻占據(jù)了一定的市場,因此導(dǎo)致了很多使用了定位技術(shù)的Andorid應(yīng)用挺尷尬的。2014-07-07

