要实现下面图的效果


代码如下

<SeekBar android:id="@android:id/progress"        style="?android:attr/progressBarStyleHorizontal"        android:progressDrawable="@drawable/seekbar_style"          android:thumb="@drawable/thumb"        android:layout_width="fill_parent"        android:layout_height="23dip"        android:paddingLeft="25dip"        android:paddingRight="25dip"        android:paddingBottom="4dip />

其实最最关键的就是
         android:progressDrawable="@drawable/seekbar_style"          android:thumb="@drawable/thumb"

怎么去定义呢?
看下面的代码:
seekbar_style.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>           <corners android:radius="10dip" />           <gradient               android:startColor="#ffffffff"             android:centerColor="#ff000000"               android:endColor="#ff808A87"              android:centerY="0.45"               android:angle="270"/>        </shape>     </item>        <item android:id="@android:id/progress">         <clip>            <shape>                <corners android:radius="10dip" />                <gradient                    android:startColor="#ffffffff"                  android:centerColor="#ffFFFF00"                    android:endColor="#ffAABD00"                   android:centerY="0.45"                    android:angle="270"/>            </shape>         </clip>     </item>   </layer-list>  


thumb.xml
<?xml version="1.0" encoding="UTF-8"?>  <selector xmlns:android="http://schemas.android.com/apk/res/android">            <!-- 按下状态 -->     <item            android:state_pressed="true"            android:drawable="@drawable/xxxxxxxxxx" />                    <!-- 普通无焦点状态 -->     <item            android:state_focused="false"            android:state_pressed="false"          android:drawable="@drawable/xxxxxxx" />上面的xxxxxxx是图片</selector>  


OK,问题解决!嘿嘿!



更多相关文章

  1. android NDK环境搭建
  2. android获取手机信息
  3. Failed to fetch URL https://dl-ssl.google.com/android/reposi
  4. Android(安卓)Studio下“Error:Could not find com.android.tool
  5. android中判断网络是否连接
  6. Android:unable to start service Intent {act = com.android.ema
  7. android中webview开启了硬件加速后会出现闪烁问题
  8. Android(安卓)和 PHP 之间进行数据加密传输
  9. android上传图片到服务器,求服务器那边和android的Activity的完整

随机推荐

  1. android:launchMode="singleTask" 与 onN
  2. android sdk+eclipse+adt 配置与开发
  3. Android中webview跟JAVASCRIPT中的交互
  4. Android轻量级缓存框架ASimpleCache
  5. 我的android 第二天 - 短信发送器
  6. Android中onInterceptTouchEvent与onTouc
  7. Android中TextVIew一些属性
  8. Android学习-五布局之相对布局
  9. Android(安卓)studio之build配置
  10. android中Acitivity的启动方式启动模式讲