Android自定義view實(shí)現(xiàn)進(jìn)度條指示效果
先看看效果圖:
首先是布局文件
<FrameLayout android:layout_width="match_parent" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_height="wrap_content"> <ProgressBar android:id="@+id/pb_process" style="@style/ProgressStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:indeterminate="false" /> <TextView android:id="@+id/tv_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textColor="@color/white"/> </FrameLayout>
添加style-ProgressStyle
<style name="TrainProgressStyle" parent="@android:style/Widget.ProgressBar.Horizontal"> <item name="android:progressDrawable">@drawable/my_progress</item> </style>
添加drawable-my_progress
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background"> <shape> <corners android:radius="5dip" /> <gradient android:angle="270" android:centerY="0.75" android:endColor="@color/gray_BB" android:startColor="@color/gray_BB" /> </shape> </item> <item android:id="@android:id/secondaryProgress"> <clip> <shape> <corners android:radius="5dip" /> <gradient android:angle="270" android:centerColor="#f69200" android:centerY="0.75" android:endColor="#ff9800" android:startColor="#ff9800" /> </shape> </clip> </item> <item android:id="@android:id/progress"> <level-list> <!-- 進(jìn)度滿時(shí) level = 10000--> <item android:maxLevel="10000" android:minLevel="10000"> <clip> <shape> <corners android:radius="5dip" /> <gradient android:angle="270" android:centerColor="#21a837" android:centerY="0.75" android:endColor="#22ac38" android:startColor="#22ac38" /> </shape> </clip> </item> <!-- 進(jìn)度未滿時(shí) level < 10000--> <item android:minLevel="0" android:maxLevel="9999" > <clip> <shape> <corners android:radius="5dip" /> <gradient android:angle="270" android:centerColor="#f69200" android:centerY="0.75" android:endColor="#ff9800" android:startColor="#ff9800" /> </shape> </clip> </item> </level-list> </item> </layer-list>
activity里的使用和安卓默認(rèn)的一樣
pb_progress.setMax(); pb_progress.setProgress();
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android動(dòng)態(tài)自定義圓形進(jìn)度條
- Android編程之ProgressBar圓形進(jìn)度條顏色設(shè)置方法
- Android帶圓形數(shù)字進(jìn)度的自定義進(jìn)度條示例
- Android實(shí)現(xiàn)帶數(shù)字的圓形進(jìn)度條(自定義進(jìn)度條)
- Android編程實(shí)現(xiàn)WebView添加進(jìn)度條的方法
- Android自定義控件實(shí)現(xiàn)圓形進(jìn)度條
- Android自定義Material進(jìn)度條效果
- android自定義view制作圓形進(jìn)度條效果
- Android編程基于自定義View實(shí)現(xiàn)絢麗的圓形進(jìn)度條功能示例
- Android實(shí)現(xiàn)環(huán)形進(jìn)度條的實(shí)例
- Android編程實(shí)現(xiàn)類似于圓形ProgressBar的進(jìn)度條效果
相關(guān)文章
Android實(shí)現(xiàn)沉浸式通知欄通知欄背景顏色跟隨app導(dǎo)航欄背景顏色而改變
這篇文章主要介紹了Android實(shí)現(xiàn)沉浸式通知欄通知欄背景顏色跟隨app導(dǎo)航欄背景顏色而改變的相關(guān)資料,需要的朋友可以參考下2016-02-02Android仿微信朋友圈點(diǎn)贊和評(píng)論功能
這篇文章主要為大家詳細(xì)介紹了Android仿微信朋友圈點(diǎn)贊和評(píng)論功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06Android動(dòng)態(tài)顯示當(dāng)前年月日時(shí)分秒系統(tǒng)時(shí)間(示例代碼)
這篇文章主要介紹了Android動(dòng)態(tài)顯示當(dāng)前年月日時(shí)分秒系統(tǒng)時(shí)間的示例代碼,需要的朋友可以參考下2017-05-05Android 使用Vitamio打造自己的萬(wàn)能播放器(4)——本地播放(快捷搜索、數(shù)據(jù)存儲(chǔ))
本文主要介紹android Vitamio 本地播放功能(快捷搜索,數(shù)據(jù)存儲(chǔ)),這里提供實(shí)例代碼和效果圖,有需要的小伙伴可以參考下2016-07-07WebView設(shè)置WebViewClient的方法
這篇文章主要介紹了 WebView設(shè)置WebViewClient的方法的相關(guān)資料,希望通過(guò)本文能幫助到大家,需要的朋友可以參考下2017-09-09Android啟動(dòng)初始化方案App StartUp的應(yīng)用詳解
這篇文章主要介紹了Android啟動(dòng)初始化方案App StartUp的使用方法,StartUp是為了App的啟動(dòng)提供的一套簡(jiǎn)單、高效的初始化方案,下面我們來(lái)詳細(xì)了解2022-09-09Android自定義View實(shí)現(xiàn)旋轉(zhuǎn)的圓形圖片
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)旋轉(zhuǎn)的圓形圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01