歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android UI之ProgressBar(進度條)

Android UI之ProgressBar(進度條)

日期:2017/3/1 10:47:05   编辑:Linux編程

進度條是一個很實用的組件,一般用來顯示用戶某個耗時操作的進度百分比,首先來看一下Android支持的幾種風格的進度條:

普通大小進度條

大進度條

大進度條

小進度條
小進度條

水平進度條

在樣式文件中分別添加這六個不同樣式的進度條,看看在模擬器上的效果

  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="fill_parent"
  8. android:layout_height="wrap_content"
  9. android:text="進度條演示" />
  10. <ProgressBar
  11. android:layout_width="wrap_content"
  12. android:layout_height="wrap_content"
  13. android:max="1000"
  14. android:progress="100"
  15. android:id="@+id/progressbar1"
  16. />
  17. <ProgressBar
  18. style="@android:style/Widget.ProgressBar.Inverse"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:max="100"
  22. android:progress="20"
  23. />
  24. <ProgressBar
  25. style="@android:style/Widget.ProgressBar.Large"
  26. android:layout_width="wrap_content"
  27. android:layout_height="wrap_content"
  28. android:max="100"
  29. android:progress="20"
  30. />
  31. <ProgressBar
  32. style="@android:style/Widget.ProgressBar.Large.Inverse"
  33. android:layout_width="wrap_content"
  34. android:layout_height="wrap_content"
  35. android:max="100"
  36. android:progress="20"
  37. />
  38. <ProgressBar
  39. style="@android:style/Widget.ProgressBar.Small"
  40. android:layout_width="wrap_content"
  41. android:layout_height="wrap_content"
  42. android:max="100"
  43. android:progress="20"
  44. />
  45. <ProgressBar
  46. style="@android:style/Widget.ProgressBar.Small.Inverse"
  47. android:layout_width="wrap_content"
  48. android:layout_height="wrap_content"
  49. android:max="100"
  50. android:progress="20"
  51. />
  52. <ProgressBar
  53. style="@android:style/Widget.ProgressBar.Horizontal"
  54. android:layout_marginTop="30dp"
  55. android:layout_width="fill_parent"
  56. android:layout_height="wrap_content"
  57. android:max="1000"
  58. android:progress="500"
  59. android:secondaryProgress="300"
  60. android:id="@+id/progressbar2"
  61. />
  62. </LinearLayout>
在模擬器上的效果:
Copyright © Linux教程網 All Rights Reserved