博主以前看到有许多学习android的人都做了音乐播放器,也就尝试着做了一个,播放器按钮背景图片资源由博客小巫的音乐播放器上抠出来的,代码纯自敲,本播放器纯用于学习,不喜勿喷,谢谢...
只讲思路,源代码结尾附上
1、播放器界面布局
<?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="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_pre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/pre_selector" />
<CheckBox
android:id="@+id/btn_repeat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:background="@drawable/repeat_seletor" />
<CheckBox
android:id="@+id/cb_playorpause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:background="@drawable/playorpause_seletor" />
<Button
android:id="@+id/btn_shuffle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/shuffle_seletor" />
<Button
android:id="@+id/btn_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/next_seletor" />
</LinearLayout>
<ListView
android:id="@+id/lv_music"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</ListView>
<SeekBar
android:id="@+id/sb_music"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/iv_music"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="8dp"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="未知"
android:textSize="16dp"
android:textColor="#FFFFFF"
android:layout_weight="1"
android:id="@+id/tv_music_name"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00"
android:textSize="16dp"
android:textColor="#FFFFFF"
android:layout_weight="1"
android:id="@+id/tv_music_duration"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>