2015-09-27 8 views
5

Der Versuch, eine benutzerdefinierte SeekBar zu machen. Ich möchte das erreichen.Android - Benutzerdefinierte SeekBar - Runde Ecken auf Fortschrittsbalken

enter image description here

Was ich bisher getan haben, ist dies. Ich finde keine Möglichkeit, die Ecken des Fortschrittsbalkens abzurunden.

enter image description here

Kann jemand helfen mit diesem? Hier ist mein Code

main_activity.xml

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:gravity="center"> 

    <SeekBar 
     android:id="@+id/seekBar1" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:progressDrawable="@drawable/styled_progress" 
     android:paddingLeft="15dp" 
     android:paddingRight="15dp" 
     android:progress="90" 
     android:thumb="@drawable/thumbler_small" 
     android:maxHeight="30dp" 
     android:layout_marginTop="125dp" 
     android:layout_marginBottom="15dp" 
     android:indeterminate="false" /> 

</LinearLayout> 

styled_progress.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

<item android:id="@android:id/background"> 
    <shape> 
     <gradient 
       android:startColor="#d2e5ff" 
       android:endColor="#d2e5ff" 
       android:angle="45" 
     /> 
     <corners 
       android:bottomRightRadius="7dp" 
       android:bottomLeftRadius="7dp" 
       android:topLeftRadius="7dp" 
       android:topRightRadius="7dp"/> 
    </shape> 
</item> 

<item android:id="@android:id/secondaryProgress"> 
    <clip> 
     <shape> 
      <gradient 
        android:startColor="#808080" 
        android:endColor="#808080" 
        android:angle="270" 
      /> 
      <corners 
       android:bottomRightRadius="7dp" 
       android:bottomLeftRadius="7dp" 
       android:topLeftRadius="7dp" 
       android:topRightRadius="7dp"/> 
     </shape> 
    </clip> 
</item> 
<item android:id="@android:id/progress"> 
    <clip> 
     <shape> 
      <gradient 
       android:startColor="#c5e6eb" 
       android:endColor="#61cabb" 
       android:angle="45" /> 
      <corners 
       android:bottomRightRadius="7dp" 
       android:bottomLeftRadius="7dp" 
       android:topLeftRadius="7dp" 
       android:topRightRadius="7dp"/> 
     </shape> 

    </clip> 
</item> 
</layer-list> 
+0

Mögliches Duplikat von [Abgerundeter Fortschritt in gerundetem Fortschrittsbalken] (http://stackoverflow.com/questions/25130359/rounded-progress-withinrounded-progress-bar) –

Antwort

2

you can see the image here

Diese sulotion war die einzige Art, wie ich dies tun könnte. Hope this Hilfe

das ist mein seekbar:

  <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" /> 

das ist (progress_background.xml):

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

und dies ist der Daumen (oval_seekbar_thumb.xml):

Die Höhe des Daumens sollte gleich sein wie die Höhe der Suchleiste, um richtig zu sehen.