自定义漂亮的Android SeekBar样式

系统自带的SeekBar真是太难看了,项目需要,只能自定义了,先来张效果图

 

第一个Seekbar 背景是颜色,thumb是图片,上代码:

 

[html]  view plain copy
 
  1. <SeekBar  
  2.         android:id="@+id/timeline"  
  3.         android:layout_width="fill_parent"  
  4.         android:layout_height="wrap_content"  
  5.         android:focusable="true"  
  6.         android:maxHeight="4.0dip"  
  7.         android:minHeight="4.0dip"  
  8.         android:paddingLeft="16.0dip"  
  9.         android:paddingRight="16.0dip"  
  10.         android:progressDrawable="@drawable/po_seekbar"  
  11.         android:thumb="@drawable/seekbar_thumb" />  

drawable/po_seekbar.xml:

[html]  view plain copy
 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <layer-list  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.     <item android:id="@*android:id/background">  
  5.         <shape>  
  6.             <solid android:color="#ff51495e" />  
  7.         </shape>  
  8.     </item>  
  9.     <item android:id="@*android:id/secondaryProgress">  
  10.         <clip>  
  11.             <shape>  
  12.                 <solid android:color="#ff51495e" />  
  13.             </shape>  
  14.         </clip>  
  15.     </item>  
  16.     <item android:id="@*android:id/progress">  
  17.         <clip>  
  18.             <shape>  
  19.                 <solid android:color="#ff996dfe" />  
  20.             </shape>  
  21.         </clip>  
  22.     </item>  
  23. </layer-list>  

drawable/seekbar_thumb.xml:

[html]  view plain copy
 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <selector  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.     <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/seekbar_thumb_normal" />  
  5.     <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />  
  6.     <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />  
  7.     <item android:drawable="@drawable/seekbar_thumb_normal" />  
  8. </selector>  


seekbar_thumb_pressed.png:

 

seekbar_thumb_normal.png:

第2个和第3个seekbar都是图片实现的

 

[html]  view plain copy
 
  1. <SeekBar  
  2.     android:id="@+id/sb_detail_play_progress"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:layout_centerVertical="true"  
  6.     android:layout_gravity="center"  
  7.     android:paddingLeft="15.0dip"  
  8.     android:paddingRight="15.0dip"  
  9.     android:progressDrawable="@drawable/progress_holo_light"  
  10.     android:thumb="@drawable/detail_icon_schedule_ball" />  


drawable/progress_holo_light.xml:

 

 

[html]  view plain copy
 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <layer-list  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.     <item android:id="@*android:id/background" android:drawable="@drawable/volumn_bg" />  
  5.     <item android:id="@*android:id/secondaryProgress">  
  6.         <scale android:drawable="@drawable/volumn_front" android:scaleWidth="100%" />  
  7.     </item>  
  8.     <item android:id="@*android:id/progress">  
  9.         <scale android:drawable="@drawable/volumn_primary" android:scaleWidth="100%" />  
  10.     </item>  
  11. </layer-list>  

volumn_bg.9.png

 

volumn_front.9.png


volumn_primary.png


第3个seekbar

这有个图片

demo下载链接:http://download.csdn.net/detail/w8320273/7800859

转载于:https://www.cnblogs.com/xiaomo8086/p/4193662.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值