自定义漂亮的Android SeekBar样式

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

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

[html] view plaincopy

  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 plaincopy

  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 plaincopy

  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 plaincopy

  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 plaincopy

  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

时间: 2024-08-29 04:35:29

自定义漂亮的Android SeekBar样式的相关文章

Android 自定义带刻度的seekbar

自定义带刻度的seekbar 1.布局 <span style="font-family:SimHei;font-size:18px;"><com.imibaby.client.views.CustomSeekbar android:id="@+id/myCustomSeekBar" android:layout_width="wrap_content" android:layout_height="wrap_cont

android中样式和自定义button样式

1)自定义button样式 一.采用图片方式 首先新建Android XML文件,类型选Drawable,根结点选selector,自定义一个文件名. 随后,开发环境自动在新建的文件里加了selector结点,我们只需要在selector结点里写上三种状态时显示的背景图片(按下.获取焦点,正常)即可.具体如下: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="

Android中自定义ActionBar的背景色等样式style

Android中想要去自定义ActionBar的背景色等样式. [折腾过程] 1.自己找代码,发现对应的配置的地方了: AndroidManifest.xml ? 1 2 <application     android:theme="@style/AppTheme" > 找到 /res/values/styles.xml 中的: ? 1 2 3 <style name="AppTheme" parent="@android:style/

Android SeekBar 和 draw9patch 的使用

今天要使用一个SeekBar控件,其实我觉得Android默认样式已经很不错了,无奈设计不同意,而且SeekBar左右两边也有图片,默认样式和图片也确实不协调,因此这里使用图片自定义SeekBar样式,首先上代码: <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:max="100" android:thumbO

Button 文字阴影,自定义图片,代码绘制样式,添加音效的方法

1.Button自己在xml文件中绑定监听器 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent&qu

自定义PreferenceActivity和PreferenceFragment的样式

感谢:http://blog.csdn.net/luck_apple/article/details/7064004 这篇文章讲的是如何定义fragment的样式,基本布局都是从源码中弄过来的.通过设置布局文件的属性,让我们可以自定义preference的界面. 先来看看xml文件中的内容 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <Preference

ProgressBar学习笔记,自定义横向进度条的样式(包含ActionBar上面的进度条)

 点显示进度条后→   android:max="100" 进度条的最大值 android:progress  进度条已经完成的进度值 android:progressDrawable 已经完成的进度条轨道显示的Drawable对象 indeterminateDrawable   设置绘制不显示进度的进度条的Drawable对象 android:indeterminate 设置为true,进度条不精准显示进度 android:indeterminateDuration  设置不精准显示

Droidicon – 1600+ 漂亮的 Android 图标

Droidicon 提供超过1600款定制图标,让你可以超级容易的把图标和徽章添加到您的应用程序中.你可以自定义你想要的各种形式的图标,给图标添加描边,透明度和颜色过滤器.包括这些 Google Material Design.Font Awesome.Iconic.Entypo 以及 Meteocons 系列. 好赞!立即下载 您可能感兴趣的相关文章 网站开发中很有用的 jQuery 效果[附源码] 分享35个让人惊讶的 CSS3 动画效果演示 十分惊艳的8个 HTML5 & JavaScri

一个简单SeekBar样式的例子

SeekBar在布局中的使用: <SeekBar android:layout_width="300px" android:layout_height="wrap_content" android:minHeight="10px"<!--定义进度条的高,不包括thumb的高--> android:maxHeight="10px"<!--定义进度条的高,不包括thumb的高--> android:t