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)度也就這是這樣,如果對配置文件的屬性不明白,請自行Google。
點(diǎn)擊下載:http://xiazai.jb51.net/201608/yuanma/andrioid-progress(jb51.net).rar
以上就是本文的全部內(nèi)容,希望對大家的學(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獲取常用輔助方法(獲取屏幕高度、寬度、密度、通知欄高度、截圖)
我們需要獲取Android手機(jī)或Pad的屏幕的物理尺寸,以便于界面的設(shè)計(jì)或是其他功能的實(shí)現(xiàn)。下面就分享一下Android中常用的一些輔助方法2016-02-02Android通知欄前臺(tái)服務(wù)的實(shí)現(xiàn)
這篇文章主要介紹了Android通知欄前臺(tái)服務(wù)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03Android 中RecyclerView頂部刷新實(shí)現(xiàn)詳解
這篇文章主要介紹了Android 中RecyclerView頂部刷新實(shí)現(xiàn)詳解的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-10-10Android 6.0動(dòng)態(tài)權(quán)限及跳轉(zhuǎn)GPS設(shè)置界面的方法
今天小編就為大家分享一篇Android 6.0動(dòng)態(tài)權(quán)限及跳轉(zhuǎn)GPS設(shè)置界面的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-07-07為Retrofit統(tǒng)一添加post請求的默認(rèn)參數(shù)的方法
這篇文章主要介紹了為Retrofit統(tǒng)一添加post請求的默認(rèn)參數(shù)的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-04-04詳解Android app自動(dòng)更新總結(jié)(已適配9.0)
這篇文章主要介紹了詳解Android app自動(dòng)更新總結(jié)(已適配9.0),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04Android使用xml文件資源定義菜單實(shí)現(xiàn)方法示例
這篇文章主要介紹了Android使用xml文件資源定義菜單實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了Android資源文件管理及xml配置自定義菜單相關(guān)操作技巧,需要的朋友可以參考下2019-03-03