具有固定编号的Android滑块

问题描述 投票:0回答:1

我正在尝试实现具有固定值的离散滑块,但是我只能设置valueFrom,valueTo和stepSize。

这是我要执行的代码

<com.google.android.material.slider.Slider
        android:id="@+id/slider"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:padding="8dp"
        app:tickColor="@color/colorSecondaryLight"
        app:tickColorActive="@color/colorSecondary" />

是否可以在滑块上设置固定值? (我将使用2、5、10、25、50和100的值)

android xml kotlin slider android-slider
1个回答
0
投票

您最好使用SeekBar

<SeekBar
     android:id="@+id/sb"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:max="10"
     android:thumb="@drawable/ic_location"
     android:theme="@style/Widget.AppCompat.SeekBar.Discrete" />
© www.soinside.com 2019 - 2024. All rights reserved.