歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android游戲開發系統控件-ProgressBar

Android游戲開發系統控件-ProgressBar

日期:2017/3/1 10:22:57   编辑:Linux編程

Android游戲開發系統空間-ProgressBar

ProgressBar(運行進度條)是較常用到的組件,例如下載進度,安裝程序進度、加載資源進度顯示條等。在Android中提供了兩種樣式分別表示在不同狀態下顯示的進度條,下面來實現這兩種樣式。

創建項目: "ProgressBarProject"

功能:顯示兩種樣式的進度條

項目運行效果圖:

項目代碼

修改布局文件

=>>main.xml

  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. <TextView
  7. android:layout_width="wrap_content"
  8. android:layout_height="wrap_content"
  9. android:text="@string/tv1"
  10. />
  11. <ProgressBar
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:text="@string/pb1"
  15. />
  16. <TextView
  17. android:layout_width="wrap_content"
  18. android:layout_height="wrap_content"
  19. android:text="@string/tv2"
  20. />
  21. <ProgressBar
  22. android:layout_width="wrap_content"
  23. android:layout_height="wrap_content"
  24. android:text="@string/pb2"
  25. style="?android:attr/progressBarStyleSmall"
  26. />
  27. <TextView
  28. android:layout_width="wrap_content"
  29. android:layout_height="wrap_content"
  30. android:text="@string/tv3"
  31. />
  32. <ProgressBar
  33. android:layout_width="wrap_content"
  34. android:layout_height="wrap_content"
  35. android:text="@string/pb3"
  36. style="?android:attr/progressBarStyleLarge"
  37. />
  38. <TextView
  39. android:layout_width="wrap_content"
  40. android:layout_height="wrap_content"
  41. android:text="@string/tv4"
  42. />
  43. <ProgressBar
  44. android:layout_width="fill_parent"
  45. android:layout_height="wrap_content"
  46. android:text="string/pb4"
  47. android:id="@+id/pb"
  48. style="?android:attr/progressBarStyleHorizontal"
  49. android:max="100"
  50. android:progress="50"
  51. android:secondaryProgress="70"
  52. />
  53. </LinearLayout>
Copyright © Linux教程網 All Rights Reserved