李发万:基于Andriod的音乐播放器设计与实现
android:layout_width=\ android:layout_height=\ android:background=\ android:baselineAligned=\ android:paddingTop=\ > android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:text=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:src=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:src=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ 25 华东交通大学理工学院毕业设计 android:src=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:src=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:text=\ />
android:visibility=\ android:layout_width=\ android:layout_height=\> android:layout_height=\ android:layout_height=\> android:layout_width=\ android:layout_height=\ /> android:layout_height=\> android:layout_width=\
android:visibility=\ android:layout_width=\ android:layout_height=\ android:gravity=\ android:layout_height=\ android:background=\> android:background=\> android:textStyle=\ android:layout_height=\/> android:layout_height=\> 27 华东交通大学理工学院毕业设计
android:layout_height=\/> android:gravity=\
android:layout_height=\ android:layout_alignParentBottom=\ /> 在绝对布局下嵌套两种线性布局 android:gravity=\ android:layout_width=\ android:textColor=\android:layout_width=\ orientation=\:此线性布局的子部件为水平方式布局 Layout_width=\:布局的宽度为填满父布局 Layout_height=\:布局的高度子由窗体的大小决定 窗体TextView 文本 :textColor=\设置文本显示的颜色RGB为 \ TextSize为默认大小 李发万:基于Andriod的音乐播放器设计与实现 4.1.2 播放界面音轨的实现 播放器音轨SeekBar(如下图) 不管是从界面外观还是从功能上,系统自带的SeekBar往往不能满足用户的需要。所以我在这里自定义了一个音轨SeekBar, 在main.Xml配置文件中,SeekBar的代码如下: android:id=\ android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:paddingLeft=\ android:paddingTop=\ android:progressDrawable=\ android:thumb=\ /> 配置文件中三个Item项依次决定了SeekBar的三层背景,从最下层的灰色到最上层的蓝色。通过各种属性设置了SeekBar的倾斜度,两端圆半径,角度,中心位置,起始,中心和结束的颜色,游标的起始位置。通过这些属性设置,就自定义一个如上图一的SeekBar音轨. 播放器最重要的一部分就是音轨与歌曲进度同步的实现。音轨设置了两个TextView用来显示当前歌曲播放的进度时间和歌曲的长度(图5.3) 图 4.2 音轨对象SeekBar在歌曲刚开始播放的时候调用方法SeekBar.setMax(),参数传入歌曲的长度。SeekBar.setProgress(1)设置游标的起始进度为1。然后程序运行如下代码: private Runnable thread_One = new Runnable() {// 线程 public void run() { int currently_Progress = seekBar.getProgress() + 1000; 29