歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android ProgressBar(進度條)的使用方法

Android ProgressBar(進度條)的使用方法

日期:2017/3/1 9:56:54   编辑:Linux編程

在Android開發中ProgressBar是經常要用到的控件,用到ProgressBar一般有兩種情況:一種是確定進度,另一種是不確定進度,今天做了一個demo分享給大家。

源碼下載地址:

免費下載地址在 http://linux.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /2013年資料/5月/28日/Android ProgressBar(進度條)的使用方法

第一步:修改新建的Android工程文件的main.xml。此處我定義了四個ProgressBar,兩個圓形和兩個條形的ProgresBar,分別用於演示確定進度和不確定進度的ProgressBar。代碼如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ProgressBar
android:id="@+id/large_indeterminate"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true" />

<ProgressBar
android:id="@+id/horizontal_indeterminate"


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true" />

<Button
android:id="@+id/indeterminate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/indeterminate" />

<ProgressBar
android:id="@+id/large_determinate"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:max="100"
android:visibility="gone" />

<ProgressBar
android:id="@+id/horizontal_determinate"

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:visibility="gone" />

<TextView
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/progress" />

<Button
android:id="@+id/determinate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/determinate" />

</LinearLayout>

Copyright © Linux教程網 All Rights Reserved