Android游戏开发系统空间-ProgressBar
ProgressBar(运行进度条)是较常用到的组件,例如下载进度,安装程序进度、加载资源进度显示条等。在Android中提供了两种样式分别表示在不同状态下显示的进度条,下面来实现这两种样式。
创建项目: "ProgressBarProject"
功能:显示两种样式的进度条
项目运行效果图:
项目代码
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/tv1"
- />
- <ProgressBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/pb1"
- />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/tv2"
- />
- <ProgressBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/pb2"
- style="?android:attr/progressBarStyleSmall"
- />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/tv3"
- />
- <ProgressBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/pb3"
- style="?android:attr/progressBarStyleLarge"
- />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/tv4"
- />
- <ProgressBar
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="string/pb4"
- android:id="@+id/pb"
- style="?android:attr/progressBarStyleHorizontal"
- android:max="100"
- android:progress="50"
- android:secondaryProgress="70"
- />
- </LinearLayout>