SoFunction
Updated on 2025-04-08

Solution to modify SeekBar style under Android

SeekBar configuration file:
Xml code
Copy the codeThe code is as follows:

<SeekBar    
         android:   
         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" background bar
The seekbar_style configuration is as follows:
Xml code
Copy the codeThe code is as follows:

<?xml version="1.0" encoding="UTF-8"?>   

<layer-list xmlns:andro>   

     <item android:>   
         <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:>   
         <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:>   
         <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>   

Or: Use the picture as follows:
Xml code
Copy the codeThe code is as follows:

<?xml version="1.0" encoding="utf-8"?>   
<layer-list xmlns:andro>   

    <item android:    
          android:drawable="@drawable/progress_bg" />   

    <item android:   
          android:drawable="@drawable/second_progress">   
    </item>       

    <item android:   
          android:drawable="@drawable/first_progress">   

    </item>    
</layer-list>   

Square
Xml code
Copy the codeThe code is as follows:

<layer-list xmlns:andro>    
    <item android:    
    android:drawable="@drawable/progress_bg" />    
    <item android:>    
     <clip android:drawable="@drawable/second_progress" />    
    </item>    
    <item android:>    
         <clip android:drawable="@drawable/first_progress" />    
    </item>    
</layer-list>   

android:thumb="@drawable/thumb" is the moving ball
The configuration is as follows:
Xml code
Copy the codeThe code is as follows:

<?xml version="1.0" encoding="UTF-8"?>   
<selector xmlns:andro>         

<!-- Press status-->
    <item    
        android:state_focused="true"    
        android:state_pressed="true"    
        android:drawable="@drawable/thumb_pressed" />         
<!-- Normal focus-free state -->
    <item    
        android:state_focused="false"    
        android:state_pressed="false"   
        android:drawable="@drawable/thumb_normal" />               
<!-- Focused state-->
    <item    
        android:state_focused="true"    
        android:state_pressed="false"               
        android:drawable="@drawable/thumb_focused" />          
<!-- With focus -->
    <item    
        android:state_focused="true"               
        android:drawable="@drawable/thumb_focused" />      
</selector>