Slider

public class Slider
extends View

java.lang.Object
   ↳ android.view.View
     ↳ com.google.android.material.slider.Slider


A widget that allows picking a value within a given range by sliding a thumb along a horizontal line.

android:value: Optional. The initial value of the slider. If not specified, the slider's minimum value android:valueFrom is used.

For more information, see the component developer guidance and design guidelines.

Summary

Nested classes

interface Slider.OnChangeListener

Interface definition for a callback invoked when a slider's value is changed. 

interface Slider.OnSliderTouchListener

Interface definition for callbacks invoked when a slider's touch event is being started/stopped. 

XML attributes

Slider_android_stepSize  
Slider_android_value  
Slider_android_valueFrom  
Slider_android_valueTo  
Slider_haloColor  
Slider_haloRadius  
Slider_labelBehavior  
Slider_thumbColor  
Slider_thumbElevation  
Slider_thumbHeight  
Slider_thumbRadius  
Slider_thumbStrokeColor  
Slider_thumbStrokeWidth  
Slider_thumbTrackGapSize  
Slider_thumbWidth  
Slider_tickColor  
Slider_tickColorActive  
Slider_tickColorInactive  
Slider_tickVisible  
Slider_trackColor  
Slider_trackColorActive  
Slider_trackColorInactive  
Slider_trackHeight  
Slider_trackInsideCornerSize  
Slider_trackStopIndicatorSize  

Inherited constants

Inherited fields

Public constructors

Slider(Context context)
Slider(Context context, AttributeSet attrs)
Slider(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

void addOnChangeListener(L listener)

Registers a callback to be invoked when the slider changes.

void addOnSliderTouchListener(T listener)

Registers a callback to be invoked when the slider touch event is being started or stopped

void clearOnChangeListeners()

Removes all instances of attached to this slider

void clearOnSliderTouchListeners()

Removes all instances of touch listeners attached to this slider

boolean dispatchHoverEvent(MotionEvent event)
boolean dispatchKeyEvent(KeyEvent event)
CharSequence getAccessibilityClassName()
int getActiveThumbIndex()

Returns the index of the currently active thumb, or -1 if no thumb is active

int getFocusedThumbIndex()

Returns the index of the currently focused thumb

int getHaloRadius()

Returns the radius of the halo.

ColorStateList getHaloTintList()

Returns the color of the halo.

int getLabelBehavior()

Returns the ERROR(/LabelBehavior) used.

float getStepSize()

Returns the step size used to mark the ticks.

float getThumbElevation()

Returns the elevation of the thumb.

int getThumbHeight()

Returns the height of the thumb.

int getThumbRadius()

Returns the radius of the thumb.

ColorStateList getThumbStrokeColor()

Gets the stroke color for the thumb.

float getThumbStrokeWidth()

Gets the stroke width for the thumb

ColorStateList getThumbTintList()

Returns the color of the thumb.

int getThumbTrackGapSize()

Returns the size of the gap between the thumb and the track.

int getThumbWidth()

Returns the width of the thumb.

int getTickActiveRadius()

Returns the radius of the active tick in pixels.

ColorStateList getTickActiveTintList()

Returns the color of the ticks on the active portion of the track.

int getTickInactiveRadius()

Returns the radius of the inactive tick in pixels.

ColorStateList getTickInactiveTintList()

Returns the color of the ticks on the inactive portion of the track.

ColorStateList getTickTintList()

Returns the color of the tick if the active and inactive parts aren't different.

ColorStateList getTrackActiveTintList()

Returns the color of the active portion of the track.

int getTrackHeight()

Returns the height of the track in pixels.

ColorStateList getTrackInactiveTintList()

Returns the color of the inactive portion of the track.

int getTrackInsideCornerSize()

Returns the corner size on the inside of the track (visible with gap).

int getTrackSidePadding()

Returns the side padding of the track.

int getTrackStopIndicatorSize()

Returns the size of the stop indicator at the edges of the track.

ColorStateList getTrackTintList()

Returns the color of the track if the active and inactive parts aren't different.

int getTrackWidth()

Returns the width of the track in pixels.

float getValue()

Returns the value of the slider.

float getValueFrom()

Returns the slider's valueFrom value.

float getValueTo()

Returns the slider's valueTo value.

boolean hasLabelFormatter()

Returns true if the slider has a LabelFormatter attached, false otherwise.

boolean isTickVisible()

Returns whether the tick marks are visible.

boolean onKeyDown(int keyCode, KeyEvent event)
boolean onKeyUp(int keyCode, KeyEvent event)
boolean onTouchEvent(MotionEvent event)
void removeOnChangeListener(L listener)

Removes a callback for value changes from this slider.

void removeOnSliderTouchListener(T listener)

Removes a callback to be invoked when the slider touch event is being started or stopped

void setCustomThumbDrawable(Drawable drawable)

Sets the custom thumb drawable which will be used for all value positions.

void setCustomThumbDrawable(int drawableResId)

Sets the custom thumb drawable which will be used for all value positions.

void setEnabled(boolean enabled)
void setFocusedThumbIndex(int index)

Sets the index of the currently focused thumb

void setHaloRadius(int radius)

Sets the radius of the halo in pixels.

void setHaloRadiusResource(int radius)

Sets the radius of the halo from a dimension resource.

void setHaloTintList(ColorStateList haloColor)

Sets the color of the halo.

void setLabelBehavior(int labelBehavior)

Determines the ERROR(/LabelBehavior) used.

void setLabelFormatter(LabelFormatter formatter)

Registers a LabelFormatter to be used to format the value displayed in the bubble shown when the slider operates in discrete mode.

void setStepSize(float stepSize)

Sets the step size to use to mark the ticks.

void setThumbElevation(float elevation)

Sets the elevation of the thumb.

void setThumbElevationResource(int elevation)

Sets the elevation of the thumb from a dimension resource.

void setThumbHeight(int height)

Sets the height of the thumb in pixels.

void setThumbHeightResource(int height)

Sets the height of the thumb from a dimension resource.

void setThumbRadius(int radius)

Sets the radius of the thumb in pixels.

void setThumbRadiusResource(int radius)

Sets the radius of the thumb from a dimension resource.

void setThumbStrokeColor(ColorStateList thumbStrokeColor)

Sets the stroke color for the thumbs.

void setThumbStrokeColorResource(int thumbStrokeColorResourceId)

Sets the stroke color resource for the thumbs.

void setThumbStrokeWidth(float thumbStrokeWidth)

Sets the stroke width for the thumb.

void setThumbStrokeWidthResource(int thumbStrokeWidthResourceId)

Sets the stroke width dimension resource for the thumb.Both thumbStroke color and thumbStroke width must be set for a stroke to be drawn.

void setThumbTintList(ColorStateList thumbColor)

Sets the color of the thumb.

void setThumbTrackGapSize(int thumbTrackGapSize)

Sets the size of the gap between the thumb and the track.

void setThumbWidth(int width)

Sets the width of the thumb in pixels.

void setThumbWidthResource(int width)

Sets the width of the thumb from a dimension resource.

void setTickActiveRadius(int tickActiveRadius)

Set the radius of the active tick in pixels.

void setTickActiveTintList(ColorStateList tickColor)

Sets the color of the ticks on the active portion of the track.

void setTickInactiveRadius(int tickInactiveRadius)

Set the radius of the inactive tick in pixels.

void setTickInactiveTintList(ColorStateList tickColor)

Sets the color of the ticks on the inactive portion of the track.

void setTickTintList(ColorStateList tickColor)

Sets the color of the tick marks.

void setTickVisible(boolean tickVisible)

Sets whether the tick marks are visible.

void setTrackActiveTintList(ColorStateList trackColor)

Sets the color of the active portion of the track.

void setTrackHeight(int trackHeight)

Set the height of the track in pixels.

void setTrackInactiveTintList(ColorStateList trackColor)

Sets the color of the inactive portion of the track.

void setTrackInsideCornerSize(int cornerSize)

Sets the corner size on the inside of the track (visible with gap).

void setTrackStopIndicatorSize(int trackStopIndicatorSize)

Sets the size of the stop indicator at the edges of the track.

void setTrackTintList(ColorStateList trackColor)

Sets the color of the track.

void setValue(float value)

Sets the value of the slider.

void setValueFrom(float valueFrom)

Sets the slider's valueFrom value.

void setValueTo(float valueTo)

Sets the slider's valueTo value.

Protected methods

void drawableStateChanged()
float getMinSeparation()
void onAttachedToWindow()
void onDetachedFromWindow()
void onDraw(Canvas canvas)
void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void onRestoreInstanceState(Parcelable state)
Parcelable onSaveInstanceState()
void onSizeChanged(int w, int h, int oldw, int oldh)
void onVisibilityChanged(View changedView, int visibility)
boolean pickActiveThumb()

Tries to pick the active thumb if one hasn't already been set.

void setActiveThumbIndex(int index)
void setSeparationUnit(int separationUnit)

Inherited methods

XML attributes

Slider_android_stepSize

Related methods:

Slider_android_value

Related methods:

Slider_android_valueFrom

Related methods:

Slider_android_valueTo

Related methods:

Slider_haloColor

Related methods:

Slider_haloRadius

Related methods:

Slider_labelBehavior

Related methods:

Slider_thumbColor

Related methods:

Slider_thumbElevation

Related methods:

Slider_thumbHeight

Related methods:

Slider_thumbRadius

Related methods:

Slider_thumbStrokeColor

Related methods:

Slider_thumbStrokeWidth

Related methods:

Slider_thumbTrackGapSize

Related methods:

Slider_thumbWidth

Related methods:

Slider_tickColor

Related methods:

Slider_tickColorActive

Related methods:

Slider_tickColorInactive

Related methods:

Slider_tickVisible

Related methods:

Slider_trackColor

Related methods:

Slider_trackColorActive

Related methods:

Slider_trackColorInactive

Related methods:

Slider_trackHeight

Related methods:

Slider_trackInsideCornerSize

Related methods:

Slider_trackStopIndicatorSize

Related methods:

Public constructors

Slider

public Slider (Context context)

Parameters
context Context

Slider

public Slider (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Slider

public Slider (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

addOnChangeListener

public void addOnChangeListener (L listener)

Registers a callback to be invoked when the slider changes. On the RangeSlider implementation, the listener is invoked once for each value.

Parameters
listener L: The callback to run when the slider changes

addOnSliderTouchListener

public void addOnSliderTouchListener (T listener)

Registers a callback to be invoked when the slider touch event is being started or stopped

Parameters
listener T: The callback to run when the slider starts or stops being touched

clearOnChangeListeners

public void clearOnChangeListeners ()

Removes all instances of attached to this slider

clearOnSliderTouchListeners

public void clearOnSliderTouchListeners ()

Removes all instances of touch listeners attached to this slider

dispatchHoverEvent

public boolean dispatchHoverEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

dispatchKeyEvent

public boolean dispatchKeyEvent (KeyEvent event)

Parameters
event KeyEvent

Returns
boolean

getAccessibilityClassName

public CharSequence getAccessibilityClassName ()

Returns
CharSequence

getActiveThumbIndex

public int getActiveThumbIndex ()

Returns the index of the currently active thumb, or -1 if no thumb is active

Returns
int

getFocusedThumbIndex

public int getFocusedThumbIndex ()

Returns the index of the currently focused thumb

Returns
int

getHaloRadius

public int getHaloRadius ()

Returns the radius of the halo.

Related XML Attributes:

Returns
int

getHaloTintList

public ColorStateList getHaloTintList ()

Returns the color of the halo.

Related XML Attributes:

Returns
ColorStateList

getLabelBehavior

public int getLabelBehavior ()

Returns the ERROR(/LabelBehavior) used.

Related XML Attributes:

Returns
int

getStepSize

public float getStepSize ()

Returns the step size used to mark the ticks.

A step size of 0 means that the slider is operating in continuous mode. A step size greater than 0 means that the slider is operating in discrete mode.

Related XML Attributes:

Returns
float

See also:

getThumbElevation

public float getThumbElevation ()

Returns the elevation of the thumb.

Related XML Attributes:

Returns
float

getThumbHeight

public int getThumbHeight ()

Returns the height of the thumb. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Returns
int

getThumbRadius

public int getThumbRadius ()

Returns the radius of the thumb. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Returns
int

getThumbStrokeColor

public ColorStateList getThumbStrokeColor ()

Gets the stroke color for the thumb.

Related XML Attributes:

Returns
ColorStateList The color used for the stroke in the thumb.

getThumbStrokeWidth

public float getThumbStrokeWidth ()

Gets the stroke width for the thumb

Related XML Attributes:

Returns
float Stroke width for the thumb.

getThumbTintList

public ColorStateList getThumbTintList ()

Returns the color of the thumb.

Related XML Attributes:

Returns
ColorStateList

getThumbTrackGapSize

public int getThumbTrackGapSize ()

Returns the size of the gap between the thumb and the track.

Related XML Attributes:

Returns
int

getThumbWidth

public int getThumbWidth ()

Returns the width of the thumb. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Returns
int

getTickActiveRadius

public int getTickActiveRadius ()

Returns the radius of the active tick in pixels.

Returns
int

getTickActiveTintList

public ColorStateList getTickActiveTintList ()

Returns the color of the ticks on the active portion of the track.

Related XML Attributes:

Returns
ColorStateList

getTickInactiveRadius

public int getTickInactiveRadius ()

Returns the radius of the inactive tick in pixels.

Returns
int

getTickInactiveTintList

public ColorStateList getTickInactiveTintList ()

Returns the color of the ticks on the inactive portion of the track.

Related XML Attributes:

Returns
ColorStateList

getTickTintList

public ColorStateList getTickTintList ()

Returns the color of the tick if the active and inactive parts aren't different.

Related XML Attributes:

Returns
ColorStateList

Throws
IllegalStateException If tickColorActive and tickColorInactive have been set to different values.

getTrackActiveTintList

public ColorStateList getTrackActiveTintList ()

Returns the color of the active portion of the track.

Related XML Attributes:

Returns
ColorStateList

getTrackHeight

public int getTrackHeight ()

Returns the height of the track in pixels.

Related XML Attributes:

Returns
int

getTrackInactiveTintList

public ColorStateList getTrackInactiveTintList ()

Returns the color of the inactive portion of the track.

Related XML Attributes:

Returns
ColorStateList

getTrackInsideCornerSize

public int getTrackInsideCornerSize ()

Returns the corner size on the inside of the track (visible with gap).

Related XML Attributes:

Returns
int

getTrackSidePadding

public int getTrackSidePadding ()

Returns the side padding of the track.

Returns
int

getTrackStopIndicatorSize

public int getTrackStopIndicatorSize ()

Returns the size of the stop indicator at the edges of the track.

Related XML Attributes:

Returns
int

getTrackTintList

public ColorStateList getTrackTintList ()

Returns the color of the track if the active and inactive parts aren't different.

Related XML Attributes:

Returns
ColorStateList

Throws
IllegalStateException If trackColorActive and trackColorInactive have been set to different values.

getTrackWidth

public int getTrackWidth ()

Returns the width of the track in pixels.

Returns
int

getValue

public float getValue ()

Returns the value of the slider.

Related XML Attributes:

Returns
float

See also:

getValueFrom

public float getValueFrom ()

Returns the slider's valueFrom value.

Related XML Attributes:

Returns
float

getValueTo

public float getValueTo ()

Returns the slider's valueTo value.

Related XML Attributes:

Returns
float

See also:

hasLabelFormatter

public boolean hasLabelFormatter ()

Returns true if the slider has a LabelFormatter attached, false otherwise.

Returns
boolean

isTickVisible

public boolean isTickVisible ()

Returns whether the tick marks are visible. Only used when the slider is in discrete mode.

Related XML Attributes:

Returns
boolean

onKeyDown

public boolean onKeyDown (int keyCode, 
                KeyEvent event)

Parameters
keyCode int

event KeyEvent

Returns
boolean

onKeyUp

public boolean onKeyUp (int keyCode, 
                KeyEvent event)

Parameters
keyCode int

event KeyEvent

Returns
boolean

onTouchEvent

public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

removeOnChangeListener

public void removeOnChangeListener (L listener)

Removes a callback for value changes from this slider.

Parameters
listener L: The callback that'll stop receive slider changes

removeOnSliderTouchListener

public void removeOnSliderTouchListener (T listener)

Removes a callback to be invoked when the slider touch event is being started or stopped

Parameters
listener T: The callback that'll stop be notified when the slider is being touched

setCustomThumbDrawable

public void setCustomThumbDrawable (Drawable drawable)

Sets the custom thumb drawable which will be used for all value positions. Note that the custom drawable provided will be resized to match the thumb radius set by setThumbRadius(int) or setThumbRadiusResource(int). Be aware that the image quality may be compromised during resizing.

Parameters
drawable Drawable

setCustomThumbDrawable

public void setCustomThumbDrawable (int drawableResId)

Sets the custom thumb drawable which will be used for all value positions. Note that the custom drawable provided will be resized to match the thumb radius set by setThumbRadius(int) or setThumbRadiusResource(int). Be aware that the image quality may be compromised during resizing.

Parameters
drawableResId int

setEnabled

public void setEnabled (boolean enabled)

Parameters
enabled boolean

setFocusedThumbIndex

public void setFocusedThumbIndex (int index)

Sets the index of the currently focused thumb

Parameters
index int

setHaloRadius

public void setHaloRadius (int radius)

Sets the radius of the halo in pixels.

Related XML Attributes:

Parameters
radius int

See also:

setHaloRadiusResource

public void setHaloRadiusResource (int radius)

Sets the radius of the halo from a dimension resource.

Related XML Attributes:

Parameters
radius int

See also:

setHaloTintList

public void setHaloTintList (ColorStateList haloColor)

Sets the color of the halo.

Related XML Attributes:

Parameters
haloColor ColorStateList

See also:

setLabelBehavior

public void setLabelBehavior (int labelBehavior)

Determines the ERROR(/LabelBehavior) used.

Related XML Attributes:

Parameters
labelBehavior int

setLabelFormatter

public void setLabelFormatter (LabelFormatter formatter)

Registers a LabelFormatter to be used to format the value displayed in the bubble shown when the slider operates in discrete mode.

Parameters
formatter LabelFormatter: The LabelFormatter to use to format the bubble's text

setStepSize

public void setStepSize (float stepSize)

Sets the step size to use to mark the ticks.

Setting this value to 0 will make the slider operate in continuous mode. Setting this value to a number greater than 0 will make the slider operate in discrete mode.

The step size must evenly divide the range described by the valueFrom and valueTo, it must be a factor of the range. If the step size is not a factor of the range, an IllegalStateException will be thrown when this view is laid out.

Setting this value to a negative value will result in an IllegalArgumentException.

Related XML Attributes:

Parameters
stepSize float: The interval value at which ticks must be drawn. Set to 0 to operate the slider in continuous mode and not have any ticks.

Throws
IllegalArgumentException If the step size is less than 0

See also:

setThumbElevation

public void setThumbElevation (float elevation)

Sets the elevation of the thumb.

Related XML Attributes:

Parameters
elevation float

setThumbElevationResource

public void setThumbElevationResource (int elevation)

Sets the elevation of the thumb from a dimension resource.

Related XML Attributes:

Parameters
elevation int

setThumbHeight

public void setThumbHeight (int height)

Sets the height of the thumb in pixels. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Parameters
height int

See also:

setThumbHeightResource

public void setThumbHeightResource (int height)

Sets the height of the thumb from a dimension resource. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Parameters
height int

See also:

setThumbRadius

public void setThumbRadius (int radius)

Sets the radius of the thumb in pixels. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Parameters
radius int

See also:

setThumbRadiusResource

public void setThumbRadiusResource (int radius)

Sets the radius of the thumb from a dimension resource. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Parameters
radius int

See also:

setThumbStrokeColor

public void setThumbStrokeColor (ColorStateList thumbStrokeColor)

Sets the stroke color for the thumbs. Both thumbStroke color and thumbStroke width must be set for a stroke to be drawn.

Related XML Attributes:

Parameters
thumbStrokeColor ColorStateList: Color to use for the stroke in the thumbs.

setThumbStrokeColorResource

public void setThumbStrokeColorResource (int thumbStrokeColorResourceId)

Sets the stroke color resource for the thumbs. Both thumbStroke color and thumbStroke width must be set for a stroke to be drawn.

Related XML Attributes:

Parameters
thumbStrokeColorResourceId int: Color resource to use for the stroke.

setThumbStrokeWidth

public void setThumbStrokeWidth (float thumbStrokeWidth)

Sets the stroke width for the thumb. Both thumbStroke color and thumbStroke width must be set for a stroke to be drawn.

Related XML Attributes:

Parameters
thumbStrokeWidth float: Stroke width for the thumb

setThumbStrokeWidthResource

public void setThumbStrokeWidthResource (int thumbStrokeWidthResourceId)

Sets the stroke width dimension resource for the thumb.Both thumbStroke color and thumbStroke width must be set for a stroke to be drawn.

Related XML Attributes:

Parameters
thumbStrokeWidthResourceId int: Stroke width dimension resource for the thumb

setThumbTintList

public void setThumbTintList (ColorStateList thumbColor)

Sets the color of the thumb.

Related XML Attributes:

Parameters
thumbColor ColorStateList

See also:

setThumbTrackGapSize

public void setThumbTrackGapSize (int thumbTrackGapSize)

Sets the size of the gap between the thumb and the track.

Related XML Attributes:

Parameters
thumbTrackGapSize int

setThumbWidth

public void setThumbWidth (int width)

Sets the width of the thumb in pixels. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Parameters
width int

See also:

setThumbWidthResource

public void setThumbWidthResource (int width)

Sets the width of the thumb from a dimension resource. Note that setting this will also affect custom drawables set through setCustomThumbDrawable(int), setCustomThumbDrawable(Drawable), ERROR(/#setCustomThumbDrawablesForValues(int...)), and ERROR(/#setCustomThumbDrawablesForValues(Drawable...)).

Related XML Attributes:

Parameters
width int

See also:

setTickActiveRadius

public void setTickActiveRadius (int tickActiveRadius)

Set the radius of the active tick in pixels.

Parameters
tickActiveRadius int

setTickActiveTintList

public void setTickActiveTintList (ColorStateList tickColor)

Sets the color of the ticks on the active portion of the track.

Related XML Attributes:

Parameters
tickColor ColorStateList

setTickInactiveRadius

public void setTickInactiveRadius (int tickInactiveRadius)

Set the radius of the inactive tick in pixels.

Parameters
tickInactiveRadius int

setTickInactiveTintList

public void setTickInactiveTintList (ColorStateList tickColor)

Sets the color of the ticks on the inactive portion of the track.

Related XML Attributes:

Parameters
tickColor ColorStateList

setTickTintList

public void setTickTintList (ColorStateList tickColor)

Sets the color of the tick marks.

Related XML Attributes:

Parameters
tickColor ColorStateList

setTickVisible

public void setTickVisible (boolean tickVisible)

Sets whether the tick marks are visible. Only used when the slider is in discrete mode.

Related XML Attributes:

Parameters
tickVisible boolean: The visibility of tick marks.

setTrackActiveTintList

public void setTrackActiveTintList (ColorStateList trackColor)

Sets the color of the active portion of the track.

Related XML Attributes:

Parameters
trackColor ColorStateList

setTrackHeight

public void setTrackHeight (int trackHeight)

Set the height of the track in pixels.

Related XML Attributes:

Parameters
trackHeight int

See also:

setTrackInactiveTintList

public void setTrackInactiveTintList (ColorStateList trackColor)

Sets the color of the inactive portion of the track.

Related XML Attributes:

Parameters
trackColor ColorStateList

setTrackInsideCornerSize

public void setTrackInsideCornerSize (int cornerSize)

Sets the corner size on the inside of the track (visible with gap).

Related XML Attributes:

Parameters
cornerSize int

setTrackStopIndicatorSize

public void setTrackStopIndicatorSize (int trackStopIndicatorSize)

Sets the size of the stop indicator at the edges of the track.

Related XML Attributes:

Parameters
trackStopIndicatorSize int

setTrackTintList

public void setTrackTintList (ColorStateList trackColor)

Sets the color of the track.

Related XML Attributes:

Parameters
trackColor ColorStateList

setValue

public void setValue (float value)

Sets the value of the slider.

The thumb value must be greater or equal to valueFrom, and lesser or equal to valueTo. If that is not the case, an IllegalStateException will be thrown when the view is laid out.

If the slider is in discrete mode (i.e. the tick increment value is greater than 0), the thumb's value must be set to a value falls on a tick (i.e.: value == valueFrom + x * stepSize, where x is an integer equal to or greater than 0). If that is not the case, an IllegalStateException will be thrown when the view is laid out.

Related XML Attributes:

Parameters
value float: The value to which to set the slider

See also:

setValueFrom

public void setValueFrom (float valueFrom)

Sets the slider's valueFrom value.

The valueFrom value must be strictly lower than the valueTo value. If that is not the case, an IllegalStateException will be thrown when the view is laid out.

Related XML Attributes:

Parameters
valueFrom float: The minimum value for the slider's range of values

See also:

setValueTo

public void setValueTo (float valueTo)

Sets the slider's valueTo value.

The valueTo value must be strictly greater than the valueFrom value. If that is not the case, an IllegalStateException will be thrown when the view is laid out.

Related XML Attributes:

Parameters
valueTo float: The maximum value for the slider's range of values

See also:

Protected methods

drawableStateChanged

protected void drawableStateChanged ()

getMinSeparation

protected float getMinSeparation ()

Returns
float

onAttachedToWindow

protected void onAttachedToWindow ()

onDetachedFromWindow

protected void onDetachedFromWindow ()

onDraw

protected void onDraw (Canvas canvas)

Parameters
canvas Canvas

onFocusChanged

protected void onFocusChanged (boolean gainFocus, 
                int direction, 
                Rect previouslyFocusedRect)

Parameters
gainFocus boolean

direction int

previouslyFocusedRect Rect

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int

onRestoreInstanceState

protected void onRestoreInstanceState (Parcelable state)

Parameters
state Parcelable

onSaveInstanceState

protected Parcelable onSaveInstanceState ()

Returns
Parcelable

onSizeChanged

protected void onSizeChanged (int w, 
                int h, 
                int oldw, 
                int oldh)

Parameters
w int

h int

oldw int

oldh int

onVisibilityChanged

protected void onVisibilityChanged (View changedView, 
                int visibility)

Parameters
changedView View

visibility int

pickActiveThumb

protected boolean pickActiveThumb ()

Tries to pick the active thumb if one hasn't already been set. This will pick the closest thumb if there is only one thumb under the touch position. If there is more than one thumb under the touch position, it will wait for enough drag left or right to determine which thumb to pick.

Returns
boolean

setActiveThumbIndex

protected void setActiveThumbIndex (int index)

Parameters
index int

setSeparationUnit

protected void setSeparationUnit (int separationUnit)

Parameters
separationUnit int