Skip to content

Attribute&Method

李涛 edited this page Sep 14, 2023 · 9 revisions

Attribute

Attributs Description
<attr name="android:value" /> Value for the slider
<attr name="android:valueFrom" /> Value from for the slider
<attr name="android:valueTo" /> Value to for the slider
<attr name="android:stepSize" /> Step size in tick mode
<attr name="trackColor" format="color" /> The color of active portion of the track
<attr name="trackColorInactive" format="color" /> The color of inactive portion of the track
<attr name="ticksColor" format="color" /> The color of the slider's tick marks for the active portion of the track
<attr name="ticksColorInactive" format="color" /> The color of the slider's tick marks for the inactive portion of the track
<attr name="ticksVisible" format="boolean" /> Whether to show the tick marks
<attr name="tickRadius" format="dimension" /> The radius of the tick
<attr name="trackHeight" format="dimension"/> The height of the track.
<attr name="trackInnerHPadding" format="dimension"/> The inner horizontal padding of the slider.
<attr name="trackInnerVPadding" format="dimension"/> The inner vertical padding of the slider.
<attr name="trackCornersRadius" format="dimension"/> The radius of the track corners.
<attr name="thumbColor" format="color"/> The color of the slider's thumb
<attr name="thumbRadius" format="dimension"/> The radius of the thumb
<attr name="thumbWidth" format="dimension"/> The width of the thumb
<attr name="thumbHeight" format="dimension"/> The height of the thumb
<attr name="thumbVOffset" format="dimension"/> The vertical offset of the thumb
<attr name="thumbElevation" format="dimension"/> The elevation of the thumb
<attr name="thumbStrokeColor" format="color" /> The stroke color for the thumb
<attr name="thumbStrokeWidth" format="dimension" /> The stroke width for the thumb
<attr name="thumbShadowColor" format="color" /> The shadow color for the thumb
<attr name="thumbWithinTrackBounds" format="boolean"/> Whether the thumb only slide within the track bounds be allowed
<attr name="thumbText" format="string"/> The text for the thumb
<attr name="thumbTextColor" format="color"/> The text color for the thumb
<attr name="thumbTextSize" format="dimension"/> The text size for the thumb
<attr name="thumbTextBold" format="boolean"/> Whether the thumb text are bold
<attr name="enableDrawHalo" format="boolean"/> Whether the draw halo is enable
<attr name="haloColor" format="color"/> The halo color for the thumb
<attr name="haloRadius" format="dimension"/> The radius for the thumb halo
<attr name="android:hapticFeedbackEnabled" format="boolean"/> Whether a slide touch should have haptic feedback enabled in tick mode
<attr name="tipViewVisible" format="boolean"/> Whether to show the tip view
<attr name="tipViewVerticalOffset" format="dimension"/> The vertical offset for tip view
<attr name="tipViewBackground" format="color"/> The background color for tip view
<attr name="tipViewTextColor" format="color"/> The text color for tip view
<attr name="tipTextAutoChange" format="boolean"/> Whether the tip text is auto change
<attr name="enableProgressAnim" format="boolean"/> Whether the enable to perform animations when the progress changes
<attr name="sliderTouchMode"/> Change user touch mode(Including 1.disable touch, 2.disable click touch, etc)

Method

Method Description
setValue(value: Float) Sets the slider’s value
setValueFrom(value: Float) Sets the slider’s value from
setValueTo(value: Float) Sets the slider’s value to
setStepSize(value: Float) Sets the step size in tick mode
setTrackInnerHPadding(padding: Int = -1) Sets the slider’s inner horizontal padding.
setTrackInnerVPadding(padding: Int) Sets the slider’s inner vertical padding.
setTrackCornersRadius(radius: Int) Sets the radius of the track corners.
setTrackTintList(color: ColorStateList) Sets the track’s color of active portion
setTrackInactiveTintList(color: ColorStateList) Sets the track’s color of inactive portion
setTicksTintList(color: ColorStateList) Sets the track’s color of the slider's tick marks for the active portion
setTicksInactiveTintList(color: ColorStateList) Sets the track’s color of the slider's tick marks for the inactive portion
setThumbText(text: String?) Sets the thumb’s text
setTickRadius(@FloatRange(from = 0.0) @Dimension tickRadius: Float) Sets the radius of the tick
setThumbRadius(@IntRange(from = 0) @Dimension radius: Int) Sets the radius of the thumb
setThumbWidthAndHeight(thumbWidth: Int,thumbHeight: Int) Sets the width and height of the thumb.this conflicts with the [setThumbRadius]
setThumbVOffset(offset: Int) Sets the vertical offset of the thumb
setThumbWithinTrackBounds(isInBounds: Boolean) Sets Whether the thumb only slide within the track bounds be allowed
setThumbTintList(thumbColor: ColorStateList) Sets the color of the slider's thumb
setThumbTextTintList(color: ColorStateList?) Sets the text color of the thumb
setThumbTextSize(size: Float) Sets the text size of the thumb
setThumbTextBold(isBold: Boolean) Sets whether the thumb text are bold
setThumbCustomDrawable(@DrawableRes drawableResId: Int) Sets the custom thumb drawable of the slider
setHaloTintList(haloColor: ColorStateList) Sets the halo color of the thumb
setHaloRadius(@IntRange(from = 0) @Dimension radius: Int) Sets the halo radius of the thumb
setThumbElevation(elevation: Float) Sets elevation of the thumb
setThumbStrokeColor(thumbStrokeColor: ColorStateList?) Sets stroke color of the thumb
setThumbStrokeWidth(thumbStrokeWidth: Float) Sets stroke width of the thumb
setThumbShadowColor(@ColorInt shadowColor: Int) Sets shadow color of the thumb
showThumb(animated:Boolean = true,delayMillis:Long = 0) Show thumb on sliders
hideThumb(animated:Boolean = true,delayMillis:Long = 0) Hide thumb on sliders
toggleThumbVisibility(animated:Boolean = true) Toggle thumb visibility
setEnableDrawHalo(enable: Boolean) Sets whether the draw halo is enable
setTipViewVisibility(visibility: Boolean) Sets whether the tip view are visible
setTipVerticalOffset(offset: Int) Sets the tip view vertical offset
setTipBackground(@ColorInt color:Int) Sets the tip view background color
setTipTextColor(@ColorInt color:Int) Sets the tip view text color
setTipTextAutoChange(isAutoChange:Boolean) Sets the tip text auto change
setTipViewClippingEnabled(enable: Boolean) Sets whether the tip view will be fully within the bounds
setTouchMode(mode: Int) Sets the slider touch mode
setOnValueChangeListener(listener: OnValueChangeListener) Registers a callback to be invoked when the slider changes(callback float value)
setOnIntValueChangeListener(listener: OnIntValueChangeListener) Registers a callback to be invoked when the slider changes(callback int value)
setOnSliderTouchListener(listener: OnSliderTouchListener) Registers a callback to be invoked when the slider touch event is being started or stopped
Clone this wiki locally