本文介绍了离散SeekBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建

我知道我可以为 SeekBar 设置最大值和最小值(我的理想解决方案是下面的 Click 示例),但我希望栏可以上下移动滑块以特定的间隔-在我的情况下为每10个.因此, SeekBar 上唯一可用的选项是;

  • 20
  • 30
  • 40
  • 50
  • 60
  • 70

是否可以为标准的Android SeekBar 定义特定的值,或者至少更改项目之间的间隔.如果没有,那么使用自定义搜索栏是否有可能?我在网上找不到任何可以解决这个问题的东西(至少不是Android系统-令人沮丧的是Google Material Design指南中公认的组件).

解决方案

I am trying to create a discrete seek bar for an Android app.

I know I can set max and min values for a SeekBar (my ideal solution would be the Click example below) but I want the bar to move up and down the slider at particular intervals - every 10 in my case. So the only options available on the SeekBar would be;

  • 20
  • 30
  • 40
  • 50
  • 60
  • 70

Is it possible to define specific values to a standard Android SeekBar or at least change the intervals between items. If not, then would it be possible with a custom seekbar? I have not found anything online which addresses this (not for Android at least - frustrating as its a recognised component in the Google Material design guidelines).

解决方案

Check this linkIf you want to implement discrete seekbar with number of gaps without using third party library then use style property of 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" />

这篇关于离散SeekBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 08:09