歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android單機版音樂盒

Android單機版音樂盒

日期:2017/3/1 10:55:44   编辑:Linux編程

這個小軟件主要用到了可以後台運行的Service組件、BroadcastReceiver組件、Intent、菜單對話框的使用及音樂的播放等。

布局很明了,通過三個線性布局的嵌套。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent">
  6. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  7. android:orientation="horizontal"
  8. android:layout_width="fill_parent"
  9. android:layout_height="wrap_content">
  10. <ImageButton
  11. android:id="@+id/start"
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:src="@drawable/png2"/>
  15. <ImageButton
  16. android:id="@+id/stop"
  17. android:layout_width="wrap_content"
  18. android:layout_height="wrap_content"
  19. android:src="@drawable/png1"/>
  20. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  21. android:orientation="vertical"
  22. android:layout_width="fill_parent"
  23. android:layout_height="fill_parent">
  24. <TextView
  25. android:id="@+id/textView1"
  26. android:layout_width="wrap_content"
  27. android:layout_height="wrap_content"
  28. android:textSize="25px"
  29. android:textColor="#ffffff"
  30. android:ellipsize="marquee"//跑馬燈效果
  31. android:layout_weight="1"
  32. android:marqueeRepeatLimit="marquee_forever"//跑馬燈無限循環
  33. android:text="@string/myTextView1"/>
  34. <TextView
  35. android:id="@+id/textView2"
  36. android:textSize="15px"
  37. android:gravity="center_vertical"
  38. android:layout_weight="1"
  39. android:layout_width="wrap_content"
  40. android:layout_height="wrap_content"
  41. android:text="@string/myTextView2"/>
  42. </LinearLayout>
  43. </LinearLayout>
  44. <ImageView
  45. android:layout_width="wrap_content"
  46. android:layout_height="wrap_content"
  47. android:src="@drawable/jinsha"
  48. />
  49. </LinearLayout>
Copyright © Linux教程網 All Rights Reserved