Seek Bar Increase Height [duplicate]
Asked Answered
B

3

14

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?

Bib answered 13/5, 2013 at 7:8 Comment(1)
-Have you fixed the height of seekbar in XML?Burkholder
M
5

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>
Marriage answered 9/7, 2020 at 8:14 Comment(0)
S
2

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.

Slashing answered 3/10, 2018 at 16:7 Comment(0)
O
0

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" />
Olives answered 29/3, 2021 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.