今天为了改进一下我的音乐播放器,就上网查了一下关于SeekBar的使用方法,本人刚学android 不久,而且本人也比较愚钝,所以呢,非得把一些事情记下来,才可能有记住这些控件使用方法。废话不说了,贴上效果图先:
这是我做的音乐播放器的效果图,虽然也不怎么好看,可是偶实在是找不到好的图片啊,没办法,将就着先看看把。
这种效果图是需呀另外编写 xml 文件的。
首先在main.xml布局中引用到 SeekBar控件,
<SeekBar
android:layout_height="7px"
android:layout_width="200dip"
android:id="@+id/seekBar1"
android:layout_below="@+id/container"
android:layout_centerHorizontal="true"
android:thumb="@drawable/thumb"
android:progressDrawable="@drawable/seekbar_style"
></SeekBar>
注意:android:thumb="@drawable/thumb" 这句话是引用到了drawable 下的thumb.xml文件,表示对与SeekBar上圆球的设置
android:progressDrawable="@drawable/seekbar_style" 这句话是引用到了drawable 下的seekbar_style.xml文件,表示对与拖动条的设置
下面是对thumb.xml的编写;
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 按下状态-->
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/edit_focused" />
<!-- 普通无焦点状态 -->
<item
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/ball" />
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/dlg_edit_focused"
></item>
</selector>
偶对图标的命名有些怪异,大家莫怪啊,,
接下来就是seekbar_style.xml的编写了
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:drawable="@drawable/progress_bacckgrounf_conew1"
></item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/progress_img_conew1"
>
</item>
</layer-list>
这个就相对简单了。。其实这些代码我也都是从别人那里看过的,然后自己稍微改改,,我用的精度条没用到secondaryProgress,所以我也没有对其进行设定,如果要用到的话,之间添加这句话就行了
<item
android:id="@android:id/secondaryProgress"
android:drawable="@drawable/progress_img_conew1">
</item>
好了,先这么写写把,这可是我的第一篇 文章啊 。。