I am working with a SeekBar
that works perfectly fine. But I want to increase the height of the Progress bar, as the native height is not as high.
So how can I change the height of the progress bar, either dynamically or through XML?
I am working with a SeekBar
that works perfectly fine. But I want to increase the height of the Progress bar, as the native height is not as high.
So how can I change the height of the progress bar, either dynamically or through XML?
To create custom seekbar, add in your xml file below code:
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/seek_homelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/_10sdp"
android:maxHeight="8dip"
android:minHeight="8dip"
android:progressBackgroundTint="@color/thumb"
android:progressDrawable="@drawable/sb_progress_drawable"
android:progressTint="@color/black"
android:secondaryProgressTint="@color/colorPrimary"
android:thumb="@drawable/sb_thumb"
android:thumbTint="@color/colorPrimary" />
Create sb_progress_drawable.xml file in drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<solid android:color="#26FFFFFF"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<scale
android:scaleWidth="100%" >
<shape android:shape="rectangle">
<solid android:color="#26FFFFFF"/>
</shape>
</scale>
</item>
<item android:id="@android:id/progress">
<scale
android:scaleWidth="100%" >
<shape android:shape="rectangle">
<solid android:color="#FFFFFF"/>
</shape>
</scale>
</item>
</layer-list>
If you want to use thumb on to seekbar then add sb_thumb.xml file in your drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<size android:width="12dp"
android:height="12dp" />
<solid android:color="@color/colorPrimary" />
</shape>
You have maxHeigh
and minHeight
attributes.
This attributes will determinate the height of your seekbar.
android:maxHeight="3dp"
android:minHeight="3dp"
https://www.lvguowei.me/post/customize-android-seekbar-color/
Cheers.
None of the above works, simply set android:layout_height="10dp"
to whatever value you want!
<SeekBar
android:id="@+id/seekBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
© 2022 - 2024 — McMap. All rights reserved.