安卓四大類進度條:android
全部進度條都繼承自ProgressBarcode
(下面這些風格爲垂直進度條的風格)繼承
聲明: 設置風格要寫成這樣: style="?android:attr/progressBarStylexxxxxx"圖片
<ProgressBar android:id="@+id/progressBar_1" android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/progressBarStyleLargeInverse" android:layout_centerInParent="true"/>
水平風格、最大進度200、當前進度140、次要進度170的進度條rem
<ProgressBar android:id="@+id/progressBar_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="200" android:progress="140" android:secondaryProgress="170" style="?android:attr/progressBarStyleHorizontal" android:layout_centerInParent="true"/>
1爲當前進度;2爲次要進度:get
ProgressBar有一個方法叫作isIndeterminate().it
用來判斷進度條是否模糊。class
沒法得知具體進度的進度條,返回true,如垂直進度條;List
能夠得知具體進度的進度條,則返回false,如水平進度條方法
ProgressBar.isIndeterminate();
實現點擊按鈕增長進度條的當前和第二進度
監聽器的實現:
class ButtonListener implements OnClickListener { public void onClick(View view) { if(view.getId() == btn_incrementProgress.getId()){ progressBar.incrementProgressBy(10); } else if(view.getId() == btn_incrementSecProgress.getId()) { progressBar.incrementSecondaryProgressBy(20); } } }