效果如下圖所示:
關鍵的代碼
public void start(View view) {
// pBar.setIndeterminate(true);
pBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.progressbar_global));
pBar.setProgressDrawable(getResources().getDrawable(
R.drawable.progressbar_global));
}
public void stop(View view) {
pBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.page_loading_bar));
pBar.setProgressDrawable(getResources().getDrawable(
R.drawable.page_loading_bar));
}
其中progressbar_global是一個animateDrawable,page_loading_bar是一個普通drawable。
一個用法是在加載頁面中使用,加載失敗讓progressbar靜止,加載時讓progressbar轉動。
還有什麼其他用處請自行發揮想象。