'Change size of Android-Seekbar?
I have a question concerning seekbars. I tried several things but nothing helped. I want to change the height of the seekbar, but not the complete seekbar, only the bar where you scroll over with your thumb. I tried several things e.g. setBackGroundDrawable and setProgressDrawable and made my own drawables, but the drawable-size is fixed to the size of the Standard-Android-Seekbar. What can I do now?
Solution 1:[1]
For changing SeekBar size custom progressDrawable and custom thumb should be used. here is full implementation:
<SeekBar
android:layout_width="your desired width in dp"
android:layout_height="wrap_content"
android:minHeight="your desired height in dp"
android:maxHeight="as same as minHeight"
android:progressDrawable="@drawable/seekbar_drawable"
android:splitTrack="false"
android:thumb="@drawable/seekbar_thumb"
/>
===========================================================
create seekbar_drawable.xml file in res/drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/seekbar_border" />
<item>
<clip android:drawable="@drawable/seekbar_progress"/>
</item>
</layer-list>
===========================================================
create seekbar_border.xml file in res/drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp" />
<solid android:color="#12000000" />
</shape>
===========================================================
create seekbar_progress.xml file in res/drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp" />
<solid android:color="#98F7DB" />
</shape>
=========================================================== and finally create seekbar_thumb.xml file in res/drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FF60C2A5" />
<size
android:width="your desired height in dp"
android:height="as same as width" />
</shape>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | AlirezA Barakati |
