Android Studio音乐播放器

1.知识要点

使用Android Studio编写一个简单的音乐盒,要求音乐盒能够实现上一首、播放/暂停、停止、下一首的功能,同时显示播放歌曲的简单信息。(需要用到BroadcastReceiver组件,它是Android的四大组件之一,用来编写广播接收者程序,对广播做出响应。)

2.项目代码

2.1xml代码

activity_main.xml

<?xml version="1.0" encoding="UTF-8"?>

<ImageButton
    android:layout_margin="10dp"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/play"
    android:id="@+id/play"/>

<ImageButton
    android:layout_margin="10dp"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/stop"
    android:id="@+id/stop"/>

<TextView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:id="@+id/title"
    android:marqueeRepeatLimit="marquee_forever"
    android:layout_weight="1"
    android:ellipsize="marquee"
    android:textColor="#9C27B0"
    android:textSize="25sp"
    android:text="@string/app_name"/>

<TextView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:id="@+id/author"
    android:layout_weight="1"
    android:textSize="25sp"
    android:gravity="center_vertical"
    android:text="@string/app_name"/>

 </LinearLayout>

2.2Java代码

  • 1
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值