用到了seekbar, so 上网找了下小demo,这位仁兄总结的很好,现转贴在这里。

原文地址:http://bashenmail.iteye.com/blog/603649

SeekBar配置文件:

Xml代码
  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代码
  1. <? xml version = "1.0" encoding = "UTF-8" ?>
  2. < layer-list xmlns:android = "http://schemas.android.com/apk/res/android" >
  3. < item android:id = "@android:id/background" >
  4. < shape >
  5. < corners android: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. < item android:id = "@android:id/secondaryProgress" >
  16. < clip >
  17. < shape >
  18. < corners android: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. < item android:id = "@android:id/progress" >
  30. < clip >
  31. < shape >
  32. < corners android: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代码
  1. <? xml version = "1.0" encoding = "utf-8" ?>
  2. < layer-list xmlns:android = "http://schemas.android.com/apk/res/android" >
  3. < item android:id = "@android:id/background"
  4. android:drawable = "@drawable/progress_bg" />
  5. < item android:id = "@android:id/secondaryProgress"
  6. android:drawable = "@drawable/second_progress" >
  7. </ item >
  8. < item android:id = "@android:id/progress"
  9. android:drawable = "@drawable/first_progress" >
  10. </ item >
  11. </ layer-list >

方形

Xml代码
  1. < layer-list xmlns:android = "http://schemas.android.com/apk/res/android" >
  2. < item android:id = "@android:id/background"
  3. android:drawable = "@drawable/progress_bg" />
  4. < item android:id = "@android:id/secondaryProgress" >
  5. < clip android:drawable = "@drawable/second_progress" />
  6. </ item >
  7. < item android:id = "@android:id/progress" >
  8. < clip android:drawable = "@drawable/first_progress" />
  9. </ item >
  10. </ layer-list >

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

配置如下:

Xml代码
  1. <? xml version = "1.0" encoding = "UTF-8" ?>
  2. < selector xmlns: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. 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
  2. PopupWindow位置
  3. Android(安卓)摄像头自动对焦的几点注意
  4. Android(安卓)Studio 设置内存大小及原理
  5. AlertDialog使用自定义的布局
  6. java.io.IOException:Can't read [F:\..\android-support-v4.ja
  7. Android应用开发之(你必须知道的android selector下的属性值)
  8. android之解析包时出现错误(二)
  9. android之点击回退键俩次退出程序

随机推荐

  1. 不正确的日期时间值:“item.purchase dat
  2. 希望为自己构建一个用于PHP + MySQL开发
  3. php图片上传并重命名图片的功能实现原理
  4. php如何以一个对象作为数组下标?
  5. 过期时间为“会话结束”的Cookie何时到期
  6. PHP打开所有报错
  7. php预定义常量目录分隔符
  8. php-自动过滤、自动填充、自动验证
  9. drupal优化全攻略
  10. 将数据从一个流传输到另一个流