2016-10-13 33 views
1

我使用一個自定義繪製了我的進度條:Android的 - 如何把在進度條運行進度圓角使用自定義XML繪製背景

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:id="@android:id/background"> 
     <shape> 
      <corners android:radius="15dp" /> 
      <solid android:color="@color/light_grey" /> 
     </shape> 
    </item> 

    <item android:id="@android:id/progress" > 
     <clip> 
      <shape> 
       <corners android:radius="15dp" /> 
       <solid android:color="@color/indigo" />     
      </shape> 
     </clip> 
    </item> 
</layer-list> 

,它看起來像:

現在

enter image description here

,背景會出現一個圓角,但進展(內部)是直的,我希望把它太圓,就像這樣:

enter image description here

我使用Google搜索,但沒有找到任何解決方案。

關於如何實現這一輪進展的任何想法?

謝謝!

回答

2

you can see example of view here

可以修改拇指的顏色和大小和搜索欄做你想做什麼。

這個解決方案是我能做到這一點的唯一方法。 希望這有助於

這是我的搜索條:

  <SeekBar 
      android:id="@+id/simpleProgressBar" 
      android:layout_width="fill_parent" 
      android:layout_height="12dp" 
      android:max="100" 
      android:progress="0" 
      android:background="@null" 
      android:shape="oval" 
      android:splitTrack="false" 
      android:progressDrawable="@drawable/progress_background" 
      android:secondaryProgress="0" 
      android:thumbOffset="10dp" 
      android:thumb="@drawable/oval_seekbar_thumb" /> 

這是(progress_background.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 android:shape="rectangle"> 
      <corners android:radius="5dp" /> 

      <gradient 
       android:angle="270" 
       android:endColor="@color/grey_line" 
       android:startColor="@color/grey_line" /> 
     </shape> 
    </item> 
    <item android:id="@android:id/secondaryProgress"> 
     <clip> 
      <shape android:shape="oval"> 
       <corners android:radius="5dp" /> 
       <gradient 
        android:angle="270" 
        android:endColor="@color/blue" 
        android:startColor="@color/blue" /> 
      </shape> 
     </clip> 
    </item> 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape android:shape="rectangle"> 
       <corners android:radius="90dp" /> 

       <gradient 
        android:angle="90" 
        android:endColor="@color/colorPrimaryDark" 
        android:startColor="@color/colorPrimary" /> 
      </shape> 
     </clip> 
    </item> 

,這是拇指(oval_seekbar_thumb.xml):

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="oval"> 
      <solid android:color="#ffffff" /> 
      <stroke android:color="@color/colorPrimaryDark" android:width="3dp"/> 
      <size android:height="12dp" android:width="12dp"/> 
     </shape> 
    </item> 
</selector> 

拇指的高度應與查找欄的高度相同以便正確查看。