自定义Android SeekBar 图片 大小 等样式

系统自带的SeekBar真是太难看了,不能容忍! 只能自己做了,先来张效果图

 

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

 

    <SeekBar
        android:id="@+id/sb_detail_play_progress"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_gravity="center"
        android:paddingLeft="15.0dip"
        android:paddingRight="15.0dip"
        android:progressDrawable="@drawable/progress_holo_light"
        android:thumb="@drawable/detail_icon_schedule_ball" />

  1.  

drawable/po_seekbar.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">
        <shape>
            <solid android:color="#ff51495e" />
        </shape>
    </item>
    <item android:id="@*android:id/secondaryProgress">
        <clip>
            <shape>
                <solid android:color="#ff51495e" />
            </shape>
        </clip>
    </item>
    <item android:id="@*android:id/progress">
        <clip>
            <shape>
                <solid android:color="#ff996dfe" />
            </shape>
        </clip>
    </item>
</layer-list>
  1.  

drawable/seekbar_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="false" android:drawable="@drawable/seekbar_thumb_normal" />

<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />

<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />

<item android:drawable="@drawable/seekbar_thumb_normal" />

</selector>
  1. 改变大小

  2. 如何改变seekbar的厚度呢,是没有属性能直接修改的,得通过重新定义样式:

     

     
  3. <SeekBar

  4. android:layout_width="match_parent"

  5. android:layout_height="wrap_content"

  6. android:layout_marginTop="20dp"

  7. android:thumb="@drawable/seek"

  8. android:progressDrawable="@drawable/seek_style"

  9. />

  10.  
  11. <?xml version="1.0" encoding="utf-8"?>

  12. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">

  13.  
  14. <size

  15. android:width="20dp"

  16. android:height="20dp"

  17. />

  18. <solid android:color="#60f0"/>

  19. </shape>


  20. progressDrawable 修改进度条的样式:

     

     
  21. <?xml version="1.0" encoding="utf-8"?>

  22. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

  23.  
  24. <item android:id="@android:id/background">

  25. <shape>

  26.  
  27. <solid android:color="#999"/>

  28. </shape>

  29. </item>

  30.  
  31. <item android:id="@android:id/secondaryProgress">

  32. <clip>

  33. <shape>

  34. <corners android:radius="5dip" />

  35. <gradient

  36. android:startColor="#80ffd300"

  37. android:centerColor="#80ffb600"

  38. android:centerY="0.75"

  39. android:endColor="#a0ffcb00"

  40. android:angle="270"

  41. />

  42. </shape>

  43. </clip>

  44. </item>

  45.  
  46. <item android:id="@android:id/progress">

  47. <clip>

  48. <shape>

  49.  
  50. <solid android:color="#600f"/>

  51. </shape>

  52. </clip>

  53. </item>

  54.  

  55. thumb 修改可拖拽的圆的样式:

     

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值