Android游戏开发系统控件-ProgressBar

Linux大全评论553 views阅读模式

Android游戏开发系统空间-ProgressBar

ProgressBar(运行进度条)是较常用到的组件,例如下载进度,安装程序进度、加载资源进度显示条等。在Android中提供了两种样式分别表示在不同状态下显示的进度条,下面来实现这两种样式。

创建项目: "ProgressBarProject"

功能:显示两种样式的进度条

项目运行效果图:

Android游戏开发系统控件-ProgressBar

项目代码

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <TextView  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content"  
  10.         android:text="@string/tv1"  
  11.         />  
  12.     <ProgressBar   
  13.         android:layout_width="wrap_content"  
  14.         android:layout_height="wrap_content"  
  15.         android:text="@string/pb1"  
  16.         />  
  17.     <TextView  
  18.         android:layout_width="wrap_content"  
  19.         android:layout_height="wrap_content"  
  20.         android:text="@string/tv2"  
  21.         />  
  22.     <ProgressBar  
  23.         android:layout_width="wrap_content"  
  24.         android:layout_height="wrap_content"  
  25.         android:text="@string/pb2"  
  26.         style="?android:attr/progressBarStyleSmall"  
  27.         />  
  28.     <TextView  
  29.         android:layout_width="wrap_content"  
  30.         android:layout_height="wrap_content"  
  31.         android:text="@string/tv3"  
  32.         />  
  33.     <ProgressBar  
  34.         android:layout_width="wrap_content"  
  35.         android:layout_height="wrap_content"  
  36.         android:text="@string/pb3"  
  37.         style="?android:attr/progressBarStyleLarge"  
  38.         />  
  39.     <TextView  
  40.         android:layout_width="wrap_content"  
  41.         android:layout_height="wrap_content"  
  42.         android:text="@string/tv4"  
  43.         />  
  44.     <ProgressBar  
  45.         android:layout_width="fill_parent"  
  46.         android:layout_height="wrap_content"  
  47.         android:text="string/pb4"  
  48.         android:id="@+id/pb"  
  49.         style="?android:attr/progressBarStyleHorizontal"  
  50.         android:max="100"  
  51.         android:progress="50"  
  52.         android:secondaryProgress="70"  
  53.         />  
  54. </LinearLayout>  

企鹅博客
  • 本文由 发表于 2019年9月7日 20:38:31
  • 转载请务必保留本文链接:https://www.qieseo.com/174931.html

发表评论