使用Kotlin的Android SeekBar

In this tutorial, we’ll discuss and implement SeekBar in our Android Application using Kotlin.

在本教程中,我们将使用Kotlin在Android应用程序中讨论和实现SeekBar。

什么是Android SeekBar? (What is Android SeekBar?)

SeekBar is a UI element that is an extension of the ProgressBar.

SeekBar是一个UI元素,它是ProgressBar的扩展。

SeekBar adds a draggable thumb to the ProgressBar. It is commonly used in music apps to provide volume control.

SeekBar将可拖动的拇指添加到ProgressBar。 它通常在音乐应用中用于提供音量控制。

SeekBar is like a scale with an upper and lower limit and every step is a single unit.

SeekBar就像一个具有上限和下限的标尺,每个步骤都是一个单位。

SeekBar XML属性 (SeekBar XML Attributes)

Some of the important XML attributes of SeekBar are:

SeekBar的一些重要XML属性是:

  • android:minWidth/maxWidth/minHeight/maxHeight: these attributes are used to set the dimensions of the seekbar view. They don’t change the thickness of the SeekBar.

    android:minWidth/maxWidth/minHeight/maxHeight :这些属性用于设置搜索栏视图的尺寸。 它们不会更改SeekBar的厚度。
  • android:max/min: The upper/lower limit of the SeekBar. The android:min is available from Android SDK 26 and above.

    android:max/min :SeekBar的上限/下限。 android:min可从Android SDK 26及更高版本中获得。
  • android:progress: The current value of the thumb position.

    android:progress :拇指位置的当前值。
  • android:progressTint: Here we pass the color for the progress to the left of the thumb position.

    android:progressTint :在这里,我们将android:progressTint的颜色传递到拇指位置的左侧。
  • android:progressBackgroundTint: This color is displayed for the SeekBar background, to the right of the thumb.

    android:progressBackgroundTint :此颜色显示在拇指右边的SeekBar背景中。
  • android:thumb: Here we can pass a custom drawable that will act as the thumb of the seek bar.

    android:thumb :这里我们可以传递一个自定义的drawable,它将用作搜索栏的拇指。
  • android:thumbTint: color of the thumb.

    android:thumbTint :拇指的颜色。
  • android:thumbOffset: The distance between the thumb and the current progress in dp. A negative value shifts the thumb to the right of the progress. A positive one shifts it to the left.

    android:thumbOffset :拇指与dp当前进度之间的距离。 负值会将拇指移到进度的右侧。 正数将其向左移动。
  • style: it’s used to set custom/predefined styles on the SeekBar. There is a popular seekbar style – “Discrete” – which breaks the progress into discrete intervals.

    style :用于在SeekBar上设置自定义/预定义的样式。 有一种流行的搜索栏样式-“离散”-将进度分为离散间隔。
  • android:tickMark: Here we pass a drawable, which acts as breakpoints on the SeekBar. The number of breakpoints/tickMarks is equal to android:max.

    android:tickMark :这里我们传递了一个drawable,它用作SeekBar上的断点。 断点/刻度标记的数量等于android:max。
  • android:tickMarkTint: used to set a color on the tickMark drawable.

    android:tickMarkTint :用于在tickMark可绘制对象上设置颜色。
  • android:splitTrack: This expects a boolean value. By default on Android Lollipop and above this
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值