用AndroidStudio播放网易云本地音乐

本文介绍如何使用Android Studio来仿照网易云音乐的播放界面,创建一个本地音乐播放功能。通过创建项目、布局文件、适配器、实体和Fragment,详细讲解了实现过程,包括处理Android 6.0以上设备的读写权限问题和获取本地音乐信息的代码实现。
摘要由CSDN通过智能技术生成
网易云音乐是一款非常优秀的音乐软件,它的播放界面由唱片机组成,显得非常的古朴典雅。
现在我们就用AndirdStudio来实现这个任务:

效果图
这里写图片描述
这里写图片描述

第一步:创建一个新的项目,例如wymusicdemo12
这里写图片描述
第二步:在java目录下的第一个文件夹下建立3个包文件
adapter、entity和fragment
第三步:建立布局文件music_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/music_item_bmg"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@mipmap/ic_launcher"/>
    <TextView
        android:id="@+id/music_item_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="成都"/>
    <TextView
        android:id="@+id/music_item_artist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="赵雷"
        android:layout_gravity="bottom"
        />

</LinearLayout>
第四步写主函数的布局文件

``
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context="com.example.user.wymusicdemo1.MainActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/mian_local_tv"
            android:layout_width=
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值