Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android seekbar discrete, how to remove step indicator

I've just discovered the seekbar discrete widget in android studio, i found it very usefull but i can't figure out how to remove the step indicators, or changing them with more appropriate drawables.

Did someone managed to do it?

Here's a screen of my current seekbar:

enter image description here

I'd like to change all the current step indicators, thank you.

EDIT:

Here's my current progress drawable:

<item android:id="@android:id/background" >
    <shape >
        <corners android:radius="20dp" />
        <gradient
            android:startColor="@color/Trasparente"
            android:centerColor="@color/Trasparente"
            android:centerX="1"
            android:endColor="@color/Trasparente"
            android:angle="0"
            />
    </shape>
</item>
<item android:id="@android:id/progress" >
    <clip android:clipOrientation="horizontal" android:gravity="left" >
        <shape>
            <corners android:radius="20dp" />
            <gradient
                android:startColor="@color/colorBluClima"
                android:centerColor="@color/colorGreenServizi"
                android:centerX="0.35"
                android:endColor="@color/colorRossoErrore"
                android:angle="0"
                />
        </shape>
    </clip>
</item>

and here's my seekbar in the layout:

 <SeekBar
            android:maxHeight="12dp"
            style="@style/Widget.AppCompat.SeekBar.Discrete"
            android:layout_width="812dp"
            android:layout_height="100dp"
            android:max="19"
            android:id="@+id/SeekBarStufa220"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginStart="90dp"
            app:layout_constraintLeft_toLeftOf="parent"
            android:layout_marginEnd="90dp"
            app:layout_constraintRight_toRightOf="parent"
            android:paddingEnd="85dp"
            android:paddingStart="85dp"
            android:progressDrawable="@drawable/progress_seek_clima"
            android:thumb="@drawable/ic_temprature"
            app:layout_constraintVertical_bias="0.79"
            android:progress="10" />

The thumb is a simple drawable

like image 760
L. Gangemi Avatar asked Feb 15 '17 08:02

L. Gangemi


Video Answer


4 Answers

I was searching for same solution, but for Material Design Slider (com.google.android.material.slider.Slider)

. I don't know since this option is available (currently i'm using 'com.google.android.material:material:1.3.0' ), but if you use code below in your layout XML, ticks will disappear.

app:tickVisible="false"
like image 56
AndroidTank Avatar answered Oct 19 '22 09:10

AndroidTank


I solved it creating a new style with SeekBar.Discrete as parent.

 <style name="SeekBarWithoutSteps" parent="Base.Widget.AppCompat.SeekBar.Discrete">
    <item name="tickMark">@null</item>
</style>
like image 40
L. Gangemi Avatar answered Oct 19 '22 08:10

L. Gangemi


if you want want to use style, you can use below xml attribute for material sliders to hide the dots

app:tickColor="#00000000"
like image 7
Hashir Labs Avatar answered Oct 19 '22 07:10

Hashir Labs


I was also searching for an answer to this but didn't find anything. I tried some things and found a style included in Android Studio (I am sure it will be also available in Eclipse and other IDEs) within the Discrete SeekBar options which is @android:style/Widget.DeviceDefault.Light.SeekBar.

I tried it with an Android 5.1 device and it worked perfectly, but be careful cause there's one which could seem to be the same (called @android:style/Widget.Material.SeekBar.Discrete) but it leaves the dots.

So I think that if the first one removes the dots from the SeekBar, it's the one you were looking for.

like image 2
Alejandro Bertinelli Avatar answered Oct 19 '22 08:10

Alejandro Bertinelli