SeekBar配置文件:

Xml代码

[xhtml] view plain copy
  1. <SeekBar
  2. android:id="@+id/player_seekbar"
  3. android:layout_width="245px"
  4. android:layout_height="25px"
  5. android:progressDrawable="@drawable/seekbar_style"
  6. android:thumb="@drawable/thumb"
  7. android:paddingLeft="16px"
  8. android:paddingRight="15px"
  9. android:paddingTop="5px"
  10. android:paddingBottom="5px"
  11. android:progress="0"
  12. android:max="0"
  13. android:secondaryProgress="0"
  14. />

android:progressDrawable="@drawable/seekbar_style"背景条

seekbar_style配置如下:

Xml代码

[xhtml] view plain copy
  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <layer-listxmlns:android="http://schemas.android.com/apk/res/android">
  3. <itemandroid:id="@android:id/background">
  4. <shape>
  5. <cornersandroid:radius="5dip"/>
  6. <gradient
  7. android:startColor="#ff9d9e9d"
  8. android:centerColor="#ff5a5d5a"
  9. android:centerY="0.75"
  10. android:endColor="#ff747674"
  11. android:angle="270"
  12. />
  13. </shape>
  14. </item>
  15. <itemandroid:id="@android:id/secondaryProgress">
  16. <clip>
  17. <shape>
  18. <cornersandroid:radius="5dip"/>
  19. <gradient
  20. android:startColor="#80ffd300"
  21. android:centerColor="#80ffb600"
  22. android:centerY="0.75"
  23. android:endColor="#a0ffcb00"
  24. android:angle="270"
  25. />
  26. </shape>
  27. </clip>
  28. </item>
  29. <itemandroid:id="@android:id/progress">
  30. <clip>
  31. <shape>
  32. <cornersandroid:radius="5dip"/>
  33. <gradient
  34. android:startColor="#ff0099CC"
  35. android:centerColor="#ff3399CC"
  36. android:centerY="0.75"
  37. android:endColor="#ff6699CC"
  38. android:angle="270"
  39. />
  40. </shape>
  41. </clip>
  42. </item>
  43. </layer-list>

或者:用图片如下:

Xml代码

[xhtml] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <layer-listxmlns:android="http://schemas.android.com/apk/res/android">
  3. <itemandroid:id="@android:id/background"
  4. android:drawable="@drawable/progress_bg"/>
  5. <itemandroid:id="@android:id/secondaryProgress"
  6. android:drawable="@drawable/second_progress">
  7. </item>
  8. <itemandroid:id="@android:id/progress"
  9. android:drawable="@drawable/first_progress">
  10. </item>
  11. </layer-list>

方形

Xml代码

[c-sharp] view plain copy
  1. <layer-listxmlns:android="http://schemas.android.com/apk/res/android">
  2. <itemandroid:id="@android:id/background"
  3. android:drawable="@drawable/progress_bg"/>
  4. <itemandroid:id="@android:id/secondaryProgress">
  5. <clipandroid:drawable="@drawable/second_progress"/>
  6. </item>
  7. <itemandroid:id="@android:id/progress">
  8. <clipandroid:drawable="@drawable/first_progress"/>
  9. </item>
  10. </layer-list>

android:thumb="@drawable/thumb"就是那个会动的球

配置如下:

Xml代码

[xhtml] view plain copy
  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <selectorxmlns:android="http://schemas.android.com/apk/res/android">
  3. <!--按下状态-->
  4. <item
  5. android:state_focused="true"
  6. android:state_pressed="true"
  7. android:drawable="@drawable/thumb_pressed"/>
  8. <!--普通无焦点状态-->
  9. <item
  10. android:state_focused="false"
  11. android:state_pressed="false"
  12. android:drawable="@drawable/thumb_normal"/>
  13. <!--有焦点状态-->
  14. <item
  15. android:state_focused="true"
  16. android:state_pressed="false"
  17. android:drawable="@drawable/thumb_focused"/>
  18. <!--有焦点-->
  19. <item
  20. android:state_focused="true"
  21. android:drawable="@drawable/thumb_focused"/>
  22. </selector>

更多相关文章

  1. Android(安卓)透明背景的dialog
  2. android播放音乐文件代码
  3. Android闪光灯开关
  4. 分享一段Android基于https协议POST数据的代码
  5. android Intent类
  6. android 使用广播监听网络状态
  7. android:taskAffinity属性的简单测试
  8. Android关于8.0以上Service服务相关问题记录
  9. Android状态栏完全透明和改变状态栏颜色实现

随机推荐

  1. Android O新特性系列
  2. xmlns:android和xmlns:mi
  3. android实现通知栏下载更新app示例
  4. Android实现语音识别代码
  5. Android中 获取手机通讯录和手机机主手机
  6. [连载 4/15] Android 从入门到精通Exampl
  7. 疯狂android讲义---intent-filter
  8. Android踩坑日记:自定义水平和圆形Progres
  9. 【极客之作】快到极致的Android模拟器—
  10. Android中Recyclerview或ListView列表条