Android下修改SeekBar样式的解决办法

 更新时间:2013年06月15日 10:53:39   作者:  
本篇文章是对在Android下修改SeekBar样式的解决办法进行了详细的分析介绍,需要的朋友参考下
SeekBar配置文件:
Xml代码
复制代码 代码如下:

<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"背景条
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="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代码
复制代码 代码如下:

<?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>   

方形
Xml代码
复制代码 代码如下:

<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">    
     <clip android:drawable="@drawable/second_progress" />    
    </item>    
    <item android:id="@android:id/progress">    
         <clip android:drawable="@drawable/first_progress" />    
    </item>    
</layer-list>   

android:thumb="@drawable/thumb"就是那个会动的球
配置如下:
Xml代码
复制代码 代码如下:

<?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> 

相关文章

  • 源码详解Android中View.post()用法

    源码详解Android中View.post()用法

    本文通过源码给大家详细分析了在Android中View.post()的用法以及经常遇到的问题和解决办法,一起来学习下。
    2017-12-12
  • Android IPC机制利用Messenger实现跨进程通信

    Android IPC机制利用Messenger实现跨进程通信

    这篇文章主要介绍了Android IPC机制中 Messager 实现跨进程通信的知识,对Android学习通信知识非常重要,需要的同学可以参考下
    2016-07-07
  • Android ContentObserver 监听短信思路详解

    Android ContentObserver 监听短信思路详解

    ContentObserver允许在Android中监控特定数据的变化,可用于短信等应用的数据监听,开发者可通过继承ContentObserver并实现onChange方法来定义当目标内容变化时的响应行为,感兴趣的朋友一起看看吧
    2024-09-09
  • 如何使用Flutter实现58同城中的加载动画详解

    如何使用Flutter实现58同城中的加载动画详解

    这篇文章主要给大家介绍了关于如何使用Flutter实现58同城中加载动画详的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用Flutter具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
    2019-10-10
  • Android打开图库选择照片功能代码

    Android打开图库选择照片功能代码

    这篇文章主要介绍了Android打开图库选择照片功能代码以及实现流程分析,对此有需要的朋友参考学习下吧。
    2018-02-02
  • AndroidStudio项目制作倒计时模块的方法

    AndroidStudio项目制作倒计时模块的方法

    本篇文章主要介绍了AndroidStudio项目制作倒计时模块的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-04-04
  • 在Android中访问WebService接口的方法

    在Android中访问WebService接口的方法

      最近公司有个项目需要从Android平台访问WebService接口,实现向发布的函数传递对象。在网上找了一些资料,发现使用ksoap2可以调用WebService传递对象。
    2013-05-05
  • Android录制声音文件(音频)并播放

    Android录制声音文件(音频)并播放

    这篇文章主要为大家详细介绍了Android录制声音文件并播放音频文件功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-11-11
  • android实现九宫格程序

    android实现九宫格程序

    这篇文章主要为大家详细介绍了android实现九宫格程序,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-06-06
  • 札记:android手势识别功能实现(利用MotionEvent)

    札记:android手势识别功能实现(利用MotionEvent)

    现在手势识别的应用已经很广泛了。本篇文章主要介绍了android手势识别功能实现,具有一定的参考价值,有兴趣的可以了解一下。
    2016-11-11

最新评论