android SeekBar 样式设置



  UI参考

 

 

 

 

 

 

 



 
 

 

Xml代码   收藏代码
  1. <SeekBar  
  2.        android:id="@+id/seekbar"  
  3.        style="?android:attr/progressBarStyleHorizontal"  
  4.        android:layout_width="fill_parent"  
  5.        android:layout_height="wrap_content"  
  6.        android:progressDrawable="@layout/seekbar_style"  
  7.        android:thumb="@layout/thumb" />  

 

 

方式一:通过背景图片设置实现

seekbar_style.xml

 

Xml代码   收藏代码
  1. xml version="1.0" encoding="UTF-8"?>  
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.       
  4.     <item android:id="@android:id/background">  
  5.           
  6.     <item android:id="@android:id/progress">  
  7.      <clip >  
  8.             <nine-patch android:src="@drawable/skin_bg2" />  
  9.      clip>  
  10.      item>  
  11. layer-list>  

 

thumb.xml

Xml代码   收藏代码
  1. xml version="1.0" encoding="UTF-8"?>  
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">  
  3.       
  4.       
  5.     <item android:drawable="@drawable/menu_bg" android:state_pressed="true"/>  
  6.       
  7.     <item android:drawable="@drawable/menu_bg" android:state_focused="false" android:state_pressed="false"/>  
  8.   
  9. selector>  

 

 

 

方式二:通过标签为SeekBar设置背景和进度的xml配置文件

seekbar_style.xml

 

Xml代码   收藏代码
  1. xml version="1.0" encoding="utf-8"?>     
  2.      
  3.     <item android:id="@android:id/background">     
  4.         <shape>     
  5.             <corners android:radius="5dip" />     
  6.             <gradient     
  7.                     android:startColor="#ffffffff"    
  8.                     android:centerColor="#fffffff0"    
  9.                     android:centerY="0.75"    
  10.                     android:endColor="#fffffafa"    
  11.                     android:angle="270"    
  12.             />     
  13.         shape>     
  14.     item>     
  15.          
  16.     <item android:id="@android:id/secondaryProgress">     
  17.         <clip>     
  18.             <shape>     
  19.                 <corners android:radius="5dip" />     
  20.                 <gradient     
  21.                         android:startColor="#8000cdcd"    
  22.                         android:centerColor="#8000bfff"    
  23.                         android:centerY="0.75"    
  24.                         android:endColor="#a000b2ee"    
  25.                         android:angle="270"    
  26.                 />     
  27.             shape>     
  28.         clip>     
  29.     item>     
  30.          
  31.     <item android:id="@android:id/progress">     
  32.         <clip>     
  33.             <shape>     
  34.                 <corners android:radius="5dip" />     
  35.                 <gradient     
  36.                         android:startColor="#ff00ffff"    
  37.                         android:centerColor="#ff00ced1"    
  38.                         android:centerY="0.75"    
  39.                         android:endColor="#ff00f5ff"    
  40.                         android:angle="270"    
  41.                 />     
  42.             shape>     
  43.         clip>     
  44.     item>     

 方式三:

Xml代码   收藏代码
  1. xml version="1.0" encoding="UTF-8"?>  
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.   
  4.       
  5.       
  6.   
  7.     <item  
  8.         android:id="@android:id/background"  
  9.         android:drawable="@drawable/timeline1">item>  
  10.       
  11.   
  12.     <item  
  13.         android:id="@android:id/progress"  
  14.         android:drawable="@drawable/timeline2">item>  
  15.   
  16. layer-list>  

 

  • SeekBar_仿天天动听.zip (55.1 KB)
  • 下载次数: 481

你可能感兴趣的:(Android,UI)