典型的SeekBar:
<SeekBar
android:id="@+id/player_seekbar"
android:layout_width="245px"
android:layout_height="25px"
android:progressDrawable="@drawable/seekbar_style"
android:thumb="@drawable/thumb"
android:paddingLeft="16px"
android:paddingRight="15px"
android:paddingTop="5px"
android:paddingBottom="5px"
android:progress="0"
android:max="0"
android:secondaryProgress="0"
/>
其中android:progressDrawable="@drawable/seekbar_style"背景条配置如下:
<?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>               <corners android:radius="5dip" />               <gradient                       android:startColor="#ff9d9e9d"                       android:centerColor="#ff5a5d5a"                       android:centerY="0.75"                       android:endColor="#ff747674"                       android:angle="270"               />           </shape>       </item>         <item android:id="@android:id/secondaryProgress">           <clip>               <shape>                   <corners android:radius="5dip" />                   <gradient                           android:startColor="#80ffd300"                           android:centerColor="#80ffb600"                           android:centerY="0.75"                           android:endColor="#a0ffcb00"                           android:angle="270"                   />               </shape>           </clip>       </item>         <item android:id="@android:id/progress">           <clip>               <shape>                   <corners android:radius="5dip" />                   <gradient                           android:startColor="#ff0099CC"                           android:centerColor="#ff3399CC"                           android:centerY="0.75"                           android:endColor="#ff6699CC"                           android:angle="270"                   />               </shape>           </clip>       </item>    </layer-list>  

或者使用图片:
<?xml version="1.0" encoding="utf-8"?>  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">             <item android:id="@android:id/background"             android:drawable="@drawable/progress_bg" />              <item android:id="@android:id/secondaryProgress"            android:drawable="@drawable/second_progress">      </item>                 <item android:id="@android:id/progress"            android:drawable="@drawable/first_progress">                 </item>   </layer-list>

android:thumb="@drawable/thumb"就是那个可以拖动的小滑块:
<?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="true"           android:drawable="@drawable/thumb_pressed" />            <!-- 普通无焦点状态 -->      <item           android:state_focused="false"           android:state_pressed="false"          android:drawable="@drawable/thumb_normal" />                  <!-- 有焦点状态-->      <item           android:state_focused="true"           android:state_pressed="false"                      android:drawable="@drawable/thumb_focused" />             <!-- 有焦点 -->      <item           android:state_focused="true"                      android:drawable="@drawable/thumb_focused" />     </selector>

更多相关文章

  1. android EditText自定义样式
  2. 沉浸式状态栏的实现
  3. Android(安卓)activity的生命周期
  4. ListView中item点击的时候颜色变化
  5. Android实现背景图与状态栏融合
  6. onRetainNonConfigurationInstance和getLastNonConfigurationIns
  7. Android如何获取网络连接状态及怎样调用网络配置界面
  8. Android(安卓)activity的生命周期
  9. Android(安卓)网络状态实时监测

随机推荐

  1. Android3.1比2.2多了一个android…
  2. android——再谈加载大量图片性能问题
  3. Android清单文件详解(一) ---- 一切从开
  4. Android(安卓)2.2 r1 API 中文文档系列(12
  5. 利用任务调度特性检测Android模拟器
  6. Android实现屏幕旋转方法总结
  7. Android和IPhone手机端开发私活
  8. Android开发实战-项目学习笔记(3)
  9. android XML解析方式
  10. Android高手进阶教程(八)之----Android(