Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom seekbar thumb not transparent on Lollipop API21

This is my seekbar:

<SeekBar     android:id="@+id/seek1"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:layout_margin="10dp"     android:progressDrawable="@drawable/style_progressbar"     android:thumb="@drawable/style_progressbar_circle"     android:progress="20" /> 

This is style_progressbar.xml:

<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/gris_hint"                 android:startColor="@color/gris_hint" />         </shape>     </item>     <item android:id="@android:id/secondaryProgress">         <clip>             <shape android:shape="rectangle" >                 <corners android:radius="5dp" />                 <gradient                     android:angle="270"                     android:endColor="@color/gris"                     android:startColor="@color/gris" />             </shape>         </clip>     </item>     <item android:id="@android:id/progress">         <clip>             <shape android:shape="rectangle" >                 <corners android:radius="5dp" />                 <gradient                     android:angle="270"                     android:endColor="@color/gris"                     android:startColor="@color/gris" />             </shape>         </clip>     </item> </layer-list> 

And this is style_progressbar_circle.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:drawable="@drawable/red_scrubber_control_disabled_holo" android:state_enabled="false"/>     <item android:drawable="@drawable/red_scrubber_control_pressed_holo" android:state_pressed="true"/>     <item android:drawable="@drawable/red_scrubber_control_focused_holo" android:state_selected="true"/>     <item android:drawable="@drawable/red_scrubber_control_normal_holo"/> </selector>     

This is how I see it in Lollipop

Seekbar Lollipop

This is how it should look, this is how it looks on Kitkat and lower versions.

Seekbar KitKat

Any idea? I've got some issues with layouts on Lollipop but this is the only one I can't solve for my own.

like image 920
deimian86 Avatar asked Nov 18 '14 08:11

deimian86


People also ask

How do I change the SeekBar thumb on Android?

Just add android:thumbTint="@color/yourColor" in your seekbar.

How do I change the color of my SeekBar line?

If you are using default SeekBar provided by android Sdk then their is a simple way to change the color of that . just go to color. xml inside /res/values/colors. xml and change the colorAccent.

How can I make SeekBar thicker?

You can use the Slider provided by the Material Components Library. Use the app:trackHeight="xxdp" (the default value is 4dp ) to change the height of the track bar. It requires the version 1.2. 0 of the library.

How do I manage SeekBar on Android?

Below are the steps for Creating SeekBar Android Application: Step1: Create a new project. After that, you will have java and XML file. Step2: Open your xml file and add a SeekBar and TextView for message as shown below, max attribute in SeekBar define the maximum it can take.


1 Answers

The Material seek bar has split track enabled by default. You need to turn it off.

<SeekBar     ....     android:splitTrack="false" /> 
like image 131
alanv Avatar answered Sep 17 '22 06:09

alanv