ProgressWheel:Android開源圓環進度條,
這是一個自訂Android組件,用於代替標準進度條組件。實現各種進度條樣式,包括圓環,掃描等。
XML:
在你的attr.xml(res/value)中加入以下
12345678910111213141516 |
<declare-styleable name="ProgressWheel"> <attr name="text"format="string"/> <attr name="textColor"format="color"/> <attr name="textSize"format="dimension"/> <attr name="barColor"format="color"/> <attr name="rimColor"format="color"/> <attr name="rimWidth"format="dimension"/> <attr name="spinSpeed"format="integer"/> <attr name="circleColor"format="color"/> <attr name="radius"format="dimension"/> <attr name="barWidth"format="dimension"/> <attr name="barLength"format="dimension"/> <attr name="delayMillis"format="dimension"/> <attr name="contourColor"format="color"/> <attr name="contourSize"format="float"/></declare-styleable> |
在你的root view 中加入
1 |
xmlns:ProgressWheel="http://schemas.android.com/apk/res/com.visualdenim.schooltraq" |
12345678910111213 |
<com.todddavies.components.progressbar.ProgressWheel android:id="@+id/pw_spinner" android:layout_width="200dp" android:layout_height="200dp" android:layout_centerInParent="true" ProgressWheel:text="Authenticating..." ProgressWheel:textColor="#222" ProgressWheel:textSize="14sp" ProgressWheel:rimColor="#330097D6" ProgressWheel:barLength="60dp" ProgressWheel:barColor="#0097D6" ProgressWheel:barWidth="5dp" ProgressWheel:rimWidth="2dp"/> |
Java:
你需要從layout中獲得進度條,或者初始化
12 |
ProgressWheel pw = newProgressWheel(myContext, myAttributes);ProgressWheel pw = (ProgressWheel) findViewById(R.id.pw_spinner); |
使用.spin() 開始進度條滾動, .stopSpinning 停止進度條滾動
增加進度有點棘手, 你可以調用.incrementProgress(), 但是這樣就超過了360度, 因為一個圓有360度, 你超過360度就會自動重設, 一個百分百自動分配