android学习之简单的音乐播放器<1>:界面设计

ContractedBlock.gif ExpandedBlockStart.gif View Code
 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" android:layout_width="fill_parent"
4 android:layout_height="fill_parent">
5 <TextView android:id="@+id/status" android:layout_width="fill_parent"
6 android:layout_height="wrap_content" android:gravity="center"
7 android:text="@string/status">
8 </TextView>
9 <ListView android:id="@+id/irclist" android:layout_width="fill_parent"
10 android:layout_height="150px">
11 </ListView>
12 <RelativeLayout android:layout_width="fill_parent"
13 android:layout_height="wrap_content">
14 <TextView android:id="@+id/currentTime" android:layout_width="wrap_content"
15 android:layout_height="wrap_content" android:layout_alignParentLeft="true"
16 android:text="@string/currentTime">
17 </TextView>
18 <TextView android:id="@+id/totalTime" android:layout_width="wrap_content"
19 android:layout_height="wrap_content" android:layout_alignParentRight="true"
20 android:text="@string/totalTime">
21 </TextView>
22
23
24 </RelativeLayout>
25 <RelativeLayout android:layout_width="fill_parent"
26 android:layout_height="wrap_content" android:orientation="horizontal"
27 android:gravity="center">
28 <ImageButton android:layout_width="wrap_content"
29 android:layout_height="wrap_content" android:src="@drawable/ic_media_rew"
30 android:id="@+id/back"></ImageButton>
31
32 <SeekBar android:id="@+id/seekBar" android:layout_width="120px"
33 android:layout_height="wrap_content" android:layout_toRightOf="@+id/back"
34
35 android:background="@color/black">
36 </SeekBar>
37 <ImageButton android:layout_width="wrap_content"
38 android:layout_height="wrap_content" android:layout_toRightOf="@+id/seekBar"
39
40 android:id="@+id/forward" android:src="@drawable/ic_media_ff">
41 </ImageButton>
42 </RelativeLayout>
43
44 <RelativeLayout android:layout_width="fill_parent"
45 android:layout_height="wrap_content" android:orientation="horizontal"
46 android:gravity="center">
47
48 <ImageButton android:layout_width="wrap_content"
49 android:layout_height="wrap_content" android:src="@drawable/ic_media_previous"
50
51
52 android:id="@+id/previous"></ImageButton>
53
54 <ImageButton android:layout_width="wrap_content"
55 android:layout_height="wrap_content" android:src="@drawable/ic_media_play"
56
57 android:layout_toRightOf="@+id/previous" android:id="@+id/play"></ImageButton>
58
59 <ImageButton android:layout_width="wrap_content"
60 android:layout_height="wrap_content" android:src="@drawable/ic_lock_power_off"
61
62 android:layout_toRightOf="@+id/play" android:id="@+id/backTbegin"></ImageButton>
63
64 <ImageButton android:layout_width="wrap_content"
65 android:layout_height="wrap_content" android:src="@drawable/ic_media_next"
66 android:layout_toRightOf="@+id/backTbegin" android:id="@+id/next"></ImageButton>
67
68
69 </RelativeLayout>
70 </LinearLayout>

上面是一个简易的音乐播放器的xml代码。

歌词滚动显示采用一个listview来显示,当点击某一个列表项时歌曲进度跳转到相应的时间,对正在播放的某一行歌词进行高亮显示。

注意点:RelativeLayout里面被其他控件属性调用的控件需要先定义在前面。例如view1控件的一个属性android:layout_toRightOf="@+id/view2" 那么view2必须在此前声明

结果图如下:

主要需求:1.播放暂停,切换歌曲,浏览歌词,按歌词播放进度,以及快进退等。

       2.播放列表管理:从文件系统添加歌曲歌词,删除/清空播放列表等。

转载于:https://www.cnblogs.com/andyLau2/archive/2011/10/09/2204840.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值