这里介绍一个简易的音乐播放器,供大家参考,具体内容如下
效果图如下:
但是,由于这是一个简易版的音乐播放器,所播放的音乐只有一首,且被写死,但,操作却十分简单,方便理解!
这是代码的主要设计:
音乐主要存放在这一个文件中:
下面就来介绍各部分代码:
activity-main.xml:
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; RelativeLayout xmlns: android=" http://schemas.android.com/apk/res/android " xmlns:工具=" http://schemas.android.com/tools " android: id=癅 + id/activity_main” android: layout_width=" match_parent " android: layout_height=" match_parent " android:背景=" # 696969 "比; LinearLayout & lt; android: layout_width=" match_parent " android: layout_height=" 60 dp " android: layout_marginTop=" 10 dp” android: layout_alignParentTop=" true " android: id=癅 + id/标题” 面向android:="水平"比; & lt; TextView android: layout_width=" match_parent " android: layout_height=" wrap_content " android: layout_marginTop=" 15 dp " android: layout_marginBottom=" 3 dp” android:文本="生僻字” android: textSize=" 25 dp " android:重力="中心" android:输入textColor=" # ffffff "/比; & lt;/LinearLayout> & lt; TextView android: layout_width=" match_parent " android: layout_height=" 0.5 dp " android:背景=" # afafaf” android: layout_below=癅 + id/标题”/比; & lt; ImageView android: id=癅 + id/盘” android: layout_width=" 280 dp” android: layout_height=" 280 dp” android: layout_centerHorizontal=" true " android: layout_below=癅 + id/标题” android: layout_marginTop=" 50 dp” android: src=" https://www.yisu.com/zixun/@drawable xcvb "/比; & lt; ImageView android: id=癅 + id/针” android: layout_width=" 120 dp” android: layout_height=" 120 dp” android: layout_below=癅 + id/标题” android: layout_marginLeft=" 150 dp/比; & lt;使用 android: id=癅 + id/music1” android: layout_width=" match_parent " android: layout_height=" wrap_content " android: layout_above=癅 + id/rl” android: layout_marginTop=" 20 dp” android: layout_marginBottom=" 10 dp” android:重力="中心"的在 & lt; SeekBar android: id=癅 + id/music_seek_bar” android: layout_width=" 240 dp” android: layout_height=" wrap_content "/比; & lt; TextSwitcher android: id=癅 + id/text_switcher” android: layout_width=" 80 dp” android: layout_height=" 50 dp” android: layout_toRightOf=癅 + id/music_seek_bar”比; & lt; TextView android: layout_width=" match_parent " android: layout_height=" wrap_content " android:文本=" 00:00/2:00 " 输入textColor=癅color/colorAccent”android:/比; & lt;/TextSwitcher> & lt;/RelativeLayout> LinearLayout & lt; android: layout_width=" match_parent " android: layout_height=" 70 dp” android:重力="中心" android: id=癅 + id/rl” android: layout_marginBottom=" 20 dp” android: layout_alignParentBottom=" true " 面向android:="水平"比; & lt; ImageView android: id=癅 + id/playing_pre” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: layout_gravity=" center_vertical " android: src=" https://www.yisu.com/zixun/@drawable music_previous "/比; & lt; ImageView android: id=癅 + id/playing_play” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: layout_gravity=" center_vertical " android: src=" https://www.yisu.com/zixun/@drawable music_play "/比; & lt; ImageView android: id=癅 + id/playing_next” android: layout_width=" wrap_content " android: layout_height=" wrap_content " android: layout_gravity=" center_vertical " android: src=" https://www.yisu.com/zixun/@drawable music_next "/比; & lt;/LinearLayout> & lt;/RelativeLayout>Android开发简易音乐播放器