看板 KnucklesNote
作者 標題 [AndroidStudio] 使用 ProgressBar 顯示載入中圖示
時間 2017-01-15 Sun. 21:18:38
使用 ProgressBar 的 StyleLarge 會像這樣
![[圖]](http://i.imgur.com/LbOkgqK.gif)
在 Layout 檔加上
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_centerInParent="true"/>
注意要放在 RelativeLayout 中,android:id="@+id/progressbar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_centerInParent="true"/>
才可以使用 android:layout_centerInParent="true"
將圖示顯示在畫面中央
要放在其他元件的後面,不然會被其他元件蓋住
在 java 檔中
新增成員變數
private ProgressBar mLoadingBar;
在成員函式 onCreate() 中加上
mLoadingBar = (ProgressBar) mContext.findViewById(R.id.progressbar);
注意要在讀取網路資料之前執行這行要顯示的時候,執行
mLoadingBar.setVisibility(View.VISIBLE);
要隱藏的時候,執行
mLoadingBar.setVisibility(View.GONE);
--
※ 作者: Knuckles 時間: 2017-01-15 21:18:38
※ 編輯: Knuckles 時間: 2017-02-25 03:31:20
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 691
回列表(←)
分享