2015-09-15 84 views
0

我正在用拇指創建自定義Seekbar。Seekbar拇指剪輯

目前,它看起來像這樣: http://imgur.com/ofVc7eg

問題: 我使用拇指(橢圓形)在進度剪輯的繪製。

我的代碼如下所示:

搜索欄佈局:

<SeekBar 
     android:background="@android:color/holo_red_light" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:thumb="@xml/thumb_image" 
     android:progressDrawable="@xml/progress" 
     android:max="100"/> 

progress.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="#FFD700" 
        android:centerColor="#FFB90F" 
        android:centerY="0.75" 
        android:endColor="#FFA500" 
        android:angle="270" 
        /> 
      </shape> 
     </clip> 
    </item> 

</layer-list> 

thumb_image.xml:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="oval" 
    android:color="@android:color/transparent"> 
    <solid android:color="@android:color/black" /> 
    <size 
     android:width="30dp" 
     android:height="30dp" /> 
</shape> 

回答