问题描述
我为用户使用搜索栏来设置他们想要的特定数量,例如,现在仅按1.1、2.2、3进行设置。 有没有办法让他们可以像这样设置它,使它可以以5为增量有两个小数位? 例如1.10、1.15、1.20、1.25(例如,较低的数字,我的搜索栏上的金额范围是0-100)
int currentValue = seekBar.getProgress();
double finalValue = currentValue / 10;
<SeekBar
android:id="@+id/seekbar"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_below="@+id/seekbarTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:max="1000" />
1楼
只需使用其他增量即可。
int currentValue = seekBar.getProgress();
double finalValue = currentValue / 20.0;
<SeekBar
android:id="@+id/seekbar"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_below="@+id/seekbarTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:max="2000" />