Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android seekbar clipped thumb

Tags:

I ran into some weird problem..I implemented a seekbar with custom thumb..and when I ran my app on HTC Desire, it all works fine..but, when I ran it on Samsung Galaxy, the thumb becomes clipped!

Here are the screenshots..

Desire:

Desire seekbar

Samsung Galaxy:

Galaxy seekbar

I would be grateful for any thoughts..tnx

myprogress.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  <item android:id="@android:id/background">     <shape>         <corners             android:radius="10dp" />         <gradient                 android:startColor="@color/gray"                 android:centerColor="@color/gray"                 android:centerY="0.75"                 android:endColor="@color/gray"                 android:angle="270"         />     </shape> </item>  <item android:id="@android:id/secondaryProgress">     <clip>         <shape>         <corners             android:radius="10dp" />             <gradient                     android:startColor="@color/white"                     android:centerColor="@color/white"                     android:centerY="0.75"                     android:endColor="@color/white"                     android:angle="270"             />         </shape>     </clip> </item>  <item android:id="@android:id/progress">     <clip>         <shape>         <corners             android:radius="10dp" />             <gradient                 android:startColor="#FFA500"                 android:centerColor="@color/yellow"                 android:centerY="0.75"                 android:endColor="@color/yellow"                 android:angle="270"             />         </shape>     </clip> </item> 

style:

<style name="mySeekBar">     <item name="android:indeterminateOnly">false</item>     <item name="android:progressDrawable">@drawable/myprogress</item>     <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>     <item name="android:minHeight">10dip</item>     <item name="android:maxHeight">10dip</item>     <item name="android:thumb">@drawable/thumb</item>     <item name="android:thumbOffset">4dp</item>     <item name="android:focusable">true</item> 

seekbar xml:

<SeekBar android:id="@+id/player_seek_horizontal"         android:layout_gravity="center_vertical"          android:max="100"          android:layout_marginLeft="50dp"          android:layout_width="180dp"          android:thumb="@drawable/thumb"          android:layout_height="wrap_content"          style="@style/mySeekBar"          android:background="@drawable/background_transparent_rounded"          android:paddingRight="4dp" android:paddingLeft="4dp"/> 
like image 260
Tomislav Novoselec Avatar asked Jun 27 '11 10:06

Tomislav Novoselec


1 Answers

Adjust the android:paddingLeft, android:paddingRight and android:thumbOffset properties of your SeekBar to achieve desired results.

Padding right and left should be half of thumb's width.

like image 72
Ragunath Jawahar Avatar answered Oct 05 '22 11:10

Ragunath Jawahar