seekbar 的用法


今天为了改进一下我的音乐播放器,就上网查了一下关于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>

好了,先这么写写把,这可是我的第一篇 文章啊 。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值