Android編程之自定義ProgressBar示例
本文實(shí)例講述了Android編程自定義ProgressBar。分享給大家供大家參考,具體如下:
<?xml version="1.0" encoding="UTF-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="360"> <shape android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="30" android:useLevel="false"> <gradient android:centerColor="#FFFFFF" android:centerY="0.01" android:endColor="#FFFFFF" android:startColor="#000000" android:type="sweep" android:useLevel="false"/> </shape> </rotate>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/base_wait_dialog2" android:gravity="center" android:padding="8dp" android:orientation="vertical"> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:indeterminateDrawable="@drawable/wait_progressbar" android:layout_marginTop="6dp"/> <TextView android:id="@+id/loadingTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="16dp" android:layout_marginTop="10dp" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:layout_marginBottom="6dp" android:gravity="center" android:text="正在加載,請(qǐng)稍等.."/> </LinearLayout>
這是ProgressBar控件,直接用android:indeterminateDrawable去引用上面的文件就可以了.
<ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:indeterminateDrawable="@drawable/wel_act_loading_pro" />
gradient里的屬性沒什么好介紹的, 這里主要是shape.
下列屬性只在android:shape="ring"
時(shí)使用:
android:innerRadiux
尺寸值,它用尺寸值或尺寸資源指定圓環(huán)內(nèi)部的半徑(指中間的圓孔的半徑)。
android:innerRadiusRatio
浮點(diǎn)值,它用圓環(huán)寬度的比率來表示內(nèi)部圓環(huán)的半徑。例如,如果android:innerRadiusRatio="5",那么內(nèi)部半徑就等于圓環(huán)的寬度除以5。這個(gè)值會(huì)被android:innerRadius的值覆蓋。默認(rèn)是9。
android:thickness
尺寸值,它用一個(gè)尺寸值或尺寸資源來定義圓環(huán)的厚度。
android:thicknessRatio
浮點(diǎn)值。它用圓環(huán)寬度的比率來表示圓環(huán)的厚度。例如,如果android:thicknessRatio="2",那么厚度就等于圓環(huán)的寬度除以2。這個(gè)值會(huì)被android:innerRadius覆蓋。默認(rèn)值是3。也就是說這個(gè)值設(shè)置的越大圓環(huán)就越細(xì)了。
android:useLevel
布爾值,如果這個(gè)形狀要用于LevelListDrawable對(duì)象,那么就設(shè)置為true。通常應(yīng)該設(shè)置為false或者讓形狀不可見。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android基本組件用法總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android布局layout技巧總結(jié)》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- Android自定義View 使用PathMeasure簡單模仿系統(tǒng)ProgressBar(四)
- Android自定義谷歌風(fēng)格ProgressBar
- Android編程實(shí)現(xiàn)自定義ProgressBar樣式示例(背景色及一級(jí)、二級(jí)進(jìn)度條顏色)
- Android三種方式實(shí)現(xiàn)ProgressBar自定義圓形進(jìn)度條
- Android編程ProgressBar自定義樣式之動(dòng)畫模式實(shí)現(xiàn)方法
- android ListView和ProgressBar(進(jìn)度條控件)的使用方法
- Android ProgressBar進(jìn)度條和ProgressDialog進(jìn)度框的展示DEMO
- Android ProgressBar進(jìn)度條使用詳解
相關(guān)文章
Android中ImageCropper矩形、圓形 裁剪框的實(shí)現(xiàn)方法
這篇文章主要給大家介紹了關(guān)于Android中ImageCropper矩形、圓形 裁剪框的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2018-07-07Android使用GridView實(shí)現(xiàn)日歷功能示例(詳細(xì)代碼)
本篇文章主要介紹了Android使用GridView實(shí)現(xiàn)日歷功能示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考,一起跟隨小編過來看看吧2017-01-01解決Android Device Monitor 的 File Explorer 中無法打開某些文件夾的問題
這篇文章主要介紹了解決Android Device Monitor 的 File Explorer 中無法打開某些文件夾的問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04Android自定義圓環(huán)倒計(jì)時(shí)控件
這篇文章主要為大家詳細(xì)介紹了Android自定義圓環(huán)倒計(jì)時(shí)控件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-09-09詳解Android中接口回調(diào)、方法回調(diào)
在Android開發(fā)中我們很多地方都用到了方法的回調(diào),回調(diào)就是把方法的定義和功能導(dǎo)入實(shí)現(xiàn)分開的一種機(jī)制,目的是為了解耦他的本質(zhì)是基于觀察者設(shè)計(jì)模式,即觀察者設(shè)計(jì)模式的的簡化版。本文主要對(duì)Android中接口回調(diào)、方法回調(diào)進(jìn)行詳細(xì)介紹,下面跟著小編一起來看下吧2017-01-01Android實(shí)現(xiàn)自定義ImageView的圓角矩形圖片效果
android顯示圓角矩形的圖片其原理就是首先獲取到圖片的Bitmap,然后進(jìn)行裁剪對(duì)應(yīng)的圓角矩形的bitmap,然后在onDraw()進(jìn)行繪制圓角矩形圖片輸出2018-05-05Android MediaPlayer音頻播放器封裝示例淺析
Android提供了許多方法來控制播放的音頻/視頻文件和流。其中該方法是通過一類稱為MediaPlayer。Android是提供MediaPlayer類訪問內(nèi)置的媒體播放器的服務(wù),如播放音頻,視頻等為了使用MediaPlayer,我們要調(diào)用這個(gè)類的靜態(tài)create()方法2023-04-04Android API開發(fā)之SMS短信服務(wù)處理和獲取聯(lián)系人的方法
這篇文章主要介紹了Android API開發(fā)之SMS短信服務(wù)處理和獲取聯(lián)系人的方法,結(jié)合實(shí)例形式分析了Android API實(shí)現(xiàn)SMS短信發(fā)送及獲取聯(lián)系人的相關(guān)操作步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-08-08Android APK使用Debug簽名重新打包 Eclipse更改默認(rèn)Debug簽名
這篇文章主要介紹了Android APK使用Debug簽名重新打包 Eclipse更改默認(rèn)Debug簽名等內(nèi)容,需要的朋友可以參考下2015-04-04