How to change the background of SeekBar?

I would like to change the background color of the SeekBar from yellow (default) to the selected color, but I found a way to change the color of the black area around the SeekBar. Can anyone help me out?

+4
source share
1 answer

xmls (background_fill, progress_fill and progress may look like that for a gradient of red

xml progress

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/background_fill" /> <item android:id="@android:id/progress"> <clip android:drawable="@drawable/progress_fill" /> </item> </layer-list> 

background_fill xml

 <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#FF555555" android:centerColor="#FF555555" android:endColor="#FF555555" android:angle="90" /> <corners android:radius="5px" /> <stroke android:width="2dp" android:color="#50999999" /> <stroke android:width="1dp" android:color="#70555555" /> </shape> 

and progress_fill xml

  <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#FF470000" android:centerColor="#FFB80000" android:endColor="#FFFF4400" android:angle="180" /> <corners android:radius="5px" /> <stroke android:width="2dp" android:color="#50999999" /> <stroke android:width="1dp" android:color="#70555555" /> </shape> 

I have not completed the implementation for android: thumb, so the thumb will still be original.

So we just need to remove this line again from our xml layout, where we define the search bar

 android:thumb="@drawable/thumb" 

for more information see link

+9
source

Source: https://habr.com/ru/post/1399639/


All Articles