Android編程之自定義ProgressBar示例
本文實例講述了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="正在加載,請稍等.."/>
</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"時使用:
android:innerRadiux
尺寸值,它用尺寸值或尺寸資源指定圓環(huán)內(nèi)部的半徑(指中間的圓孔的半徑)。
android:innerRadiusRatio
浮點值,它用圓環(huán)寬度的比率來表示內(nèi)部圓環(huán)的半徑。例如,如果android:innerRadiusRatio="5",那么內(nèi)部半徑就等于圓環(huán)的寬度除以5。這個值會被android:innerRadius的值覆蓋。默認(rèn)是9。
android:thickness
尺寸值,它用一個尺寸值或尺寸資源來定義圓環(huán)的厚度。
android:thicknessRatio
浮點值。它用圓環(huán)寬度的比率來表示圓環(huán)的厚度。例如,如果android:thicknessRatio="2",那么厚度就等于圓環(huán)的寬度除以2。這個值會被android:innerRadius覆蓋。默認(rèn)值是3。也就是說這個值設(shè)置的越大圓環(huán)就越細(xì)了。
android:useLevel
布爾值,如果這個形狀要用于LevelListDrawable對象,那么就設(shè)置為true。通常應(yīng)該設(shè)置為false或者讓形狀不可見。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android基本組件用法總結(jié)》、《Android開發(fā)入門與進階教程》、《Android布局layout技巧總結(jié)》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計有所幫助。
- Android自定義View 使用PathMeasure簡單模仿系統(tǒng)ProgressBar(四)
- Android自定義谷歌風(fēng)格ProgressBar
- Android編程實現(xiàn)自定義ProgressBar樣式示例(背景色及一級、二級進度條顏色)
- Android三種方式實現(xiàn)ProgressBar自定義圓形進度條
- Android編程ProgressBar自定義樣式之動畫模式實現(xiàn)方法
- android ListView和ProgressBar(進度條控件)的使用方法
- Android ProgressBar進度條和ProgressDialog進度框的展示DEMO
- Android ProgressBar進度條使用詳解
相關(guān)文章
Android progressbar實現(xiàn)帶底部指示器和文字的進度條
這篇文章主要為大家詳細(xì)介紹了Android progressbar實現(xiàn)帶底部指示器和文字的進度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-01-01
Android編程動態(tài)修改RelativeLayout寬高的方法
這篇文章主要介紹了Android編程動態(tài)修改RelativeLayout寬高的方法,涉及Android動態(tài)布局的相關(guān)技巧,需要的朋友可以參考下2015-12-12
Android應(yīng)用開發(fā)中Fragment的靜態(tài)加載與動態(tài)加載實例
這篇文章主要介紹了Android應(yīng)用開發(fā)中Fragment的靜態(tài)加載與動態(tài)加載實例,例子中包括動態(tài)的添加更新以及刪除Fragment等操作,很有借鑒意義,需要的朋友可以參考下2016-02-02
Android LaunchMode四種啟動模式詳細(xì)介紹
這篇文章主要介紹了Android LaunchMode四種啟動模式詳細(xì)介紹的相關(guān)資料,這里對launchmode的使用方法進行了詳解及啟動模式的比較,需要的朋友可以參考下2016-12-12
Android中AlertDialog各種對話框的用法實例詳解
這篇文章主要介紹了Android中AlertDialog各種對話框的用法在項目開發(fā)中經(jīng)常用的到,本文給大家介紹的非常詳細(xì),具有參考借鑒價值2016-04-04
Android編程實現(xiàn)TextView部分顏色變動的方法
這篇文章主要介紹了Android編程實現(xiàn)TextView部分顏色變動的方法,涉及Android針對TextView樣式操作的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11
Android開發(fā)基于ViewPager+GridView實現(xiàn)仿大眾點評橫向滑動功能
這篇文章主要介紹了Android開發(fā)基于ViewPager+GridView實現(xiàn)仿大眾點評橫向滑動功能,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09
Android Adapter里面嵌套ListView實例詳解
這篇文章主要介紹了Android Adapter里面嵌套ListView實例詳解的相關(guān)資料,這里提供實例代碼并說明如何實現(xiàn)該功能,需要的朋友可以參考下2017-07-07

