Android APIs
public abstract class

AbsSeekBar

extends ProgressBar
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.ProgressBar
       ↳ android.widget.AbsSeekBar
Known Direct Subclasses
Known Indirect Subclasses

Summary

XML Attributes
Attribute Name Related Method Description
android:thumbTint setThumbTintList(ColorStateList) Tint to apply to the button graphic. 
android:thumbTintMode setThumbTintMode(PorterDuff.Mode) Blending mode used to apply the button graphic tint. 
[Expand]
Inherited XML Attributes
From class android.widget.ProgressBar
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
AbsSeekBar(Context context)
AbsSeekBar(Context context, AttributeSet attrs)
AbsSeekBar(Context context, AttributeSet attrs, int defStyleAttr)
AbsSeekBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void drawableHotspotChanged(float x, float y)
This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.
int getKeyProgressIncrement()
Returns the amount of progress changed via the arrow keys.
boolean getSplitTrack()
Returns whether the track should be split by the thumb.
Drawable getThumb()
Return the drawable used to represent the scroll thumb - the component that the user can drag back and forth indicating the current value by its position.
int getThumbOffset()
ColorStateList getThumbTintList()
Returns the tint applied to the thumb drawable, if specified.
PorterDuff.Mode getThumbTintMode()
Returns the blending mode used to apply the tint to the thumb drawable, if specified.
void jumpDrawablesToCurrentState()
Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.
void onInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
Initializes an AccessibilityNodeInfo with information about this view.
boolean onKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is enabled and clickable.
void onRtlPropertiesChanged(int layoutDirection)
Called when any RTL property (layout direction or text direction or text alignment) has been changed.
boolean onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
boolean performAccessibilityAction(int action, Bundle arguments)
Performs the specified accessibility action on the view.
void setKeyProgressIncrement(int increment)
Sets the amount of progress changed via the arrow keys.
synchronized void setMax(int max)

Set the range of the progress bar to 0...

void setSplitTrack(boolean splitTrack)
Specifies whether the track should be split by the thumb.
void setThumb(Drawable thumb)
Sets the thumb that will be drawn at the end of the progress meter within the SeekBar.
void setThumbOffset(int thumbOffset)
Sets the thumb offset that allows the thumb to extend out of the range of the track.
void setThumbTintList(ColorStateList tint)
Applies a tint to the thumb drawable.
void setThumbTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by setThumbTintList(ColorStateList)} to the thumb drawable.
Protected Methods
void drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
synchronized void onDraw(Canvas canvas)
Implement this to do your drawing.
synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

void onSizeChanged(int w, int h, int oldw, int oldh)
This is called during layout when the size of this view has changed.
boolean verifyDrawable(Drawable who)
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.
[Expand]
Inherited Methods
From class android.widget.ProgressBar
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

android:thumbTint

Tint to apply to the button graphic.

Must be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol thumbTint.

android:thumbTintMode

Blending mode used to apply the button graphic tint.

Must be one of the following constant values.

ConstantValueDescription
src_over3 The tint is drawn on top of the drawable. [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc]
src_in5 The tint is masked by the alpha channel of the drawable. The drawable’s color channels are thrown out. [Sa * Da, Sc * Da]
src_atop9 The tint is drawn above the drawable, but with the drawable’s alpha channel masking the result. [Da, Sc * Da + (1 - Sa) * Dc]
multiply14 Multiplies the color and alpha channels of the drawable with those of the tint. [Sa * Da, Sc * Dc]
screen15 [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
add16 Combines the tint and drawable color and alpha channels, clamping the result to valid color values. Saturate(S + D)

This corresponds to the global attribute resource symbol thumbTintMode.

Public Constructors

public AbsSeekBar (Context context)

Added in API level 1

public AbsSeekBar (Context context, AttributeSet attrs)

Added in API level 1

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

Added in API level 1

public AbsSeekBar (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Added in API level 21

Public Methods

public void drawableHotspotChanged (float x, float y)

Added in API level 21

This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.

Dispatching to child views is handled by dispatchDrawableHotspotChanged(float, float).

Be sure to call through to the superclass when overriding this function.

Parameters
x hotspot x coordinate
y hotspot y coordinate

public int getKeyProgressIncrement ()

Added in API level 3

Returns the amount of progress changed via the arrow keys.

By default, this will be a value that is derived from the max progress.

Returns
  • The amount to increment or decrement when the user presses the arrow keys. This will be positive.

public boolean getSplitTrack ()

Added in API level 21

Returns whether the track should be split by the thumb.

public Drawable getThumb ()

Added in API level 16

Return the drawable used to represent the scroll thumb - the component that the user can drag back and forth indicating the current value by its position.

Returns
  • The current thumb drawable

public int getThumbOffset ()

Added in API level 1

public ColorStateList getThumbTintList ()

Added in API level 21

Returns the tint applied to the thumb drawable, if specified.

Related XML Attributes
Returns
  • the tint applied to the thumb drawable

public PorterDuff.Mode getThumbTintMode ()

Added in API level 21

Returns the blending mode used to apply the tint to the thumb drawable, if specified.

Related XML Attributes
Returns
  • the blending mode used to apply the tint to the thumb drawable

public void jumpDrawablesToCurrentState ()

Added in API level 11

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

Also calls jumpToCurrentState() if there is a StateListAnimator attached to this view.

public void onInitializeAccessibilityEvent (AccessibilityEvent event)

Added in API level 14

Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

 public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
     super.onInitializeAccessibilityEvent(event);
     event.setPassword(true);
 }

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

Parameters
event The event to initialize.

public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Added in API level 14

Initializes an AccessibilityNodeInfo with information about this view. The base implementation sets:

Subclasses should override this method, call the super implementation, and set additional attributes.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) is responsible for handling this call.

Parameters
info The instance to initialize.

public boolean onKeyDown (int keyCode, KeyEvent event)

Added in API level 1

Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is enabled and clickable.

Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

Parameters
keyCode A key code that represents the button pressed, from KeyEvent.
event The KeyEvent object that defines the button action.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public void onRtlPropertiesChanged (int layoutDirection)

Added in API level 17

Called when any RTL property (layout direction or text direction or text alignment) has been changed. Subclasses need to override this method to take care of cached information that depends on the resolved layout direction, or to inform child views that inherit their layout direction. The default implementation does nothing.

Parameters
layoutDirection the direction of the layout

public boolean onTouchEvent (MotionEvent event)

Added in API level 1

Implement this method to handle touch screen motion events.

If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling performClick(). This will ensure consistent system behavior, including:

  • obeying click sound preferences
  • dispatching OnClickListener calls
  • handling ACTION_CLICK when accessibility features are enabled

Parameters
event The motion event.
Returns
  • True if the event was handled, false otherwise.

public boolean performAccessibilityAction (int action, Bundle arguments)

Added in API level 16

Performs the specified accessibility action on the view. For possible accessibility actions look at AccessibilityNodeInfo.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its performAccessibilityAction(View, int, Bundle) is responsible for handling this call.

The default implementation will delegate ACTION_SCROLL_BACKWARD and ACTION_SCROLL_FORWARD to nested scrolling parents if nested scrolling is enabled on this view.

Parameters
action The action to perform.
arguments Optional action arguments.
Returns
  • Whether the action was performed.

public void setKeyProgressIncrement (int increment)

Added in API level 3

Sets the amount of progress changed via the arrow keys.

Parameters
increment The amount to increment or decrement when the user presses the arrow keys.

public synchronized void setMax (int max)

Added in API level 1

Set the range of the progress bar to 0...max.

Parameters
max the upper range of this progress bar

public void setSplitTrack (boolean splitTrack)

Added in API level 21

Specifies whether the track should be split by the thumb. When true, the thumb's optical bounds will be clipped out of the track drawable, then the thumb will be drawn into the resulting gap.

Parameters
splitTrack Whether the track should be split by the thumb

public void setThumb (Drawable thumb)

Added in API level 1

Sets the thumb that will be drawn at the end of the progress meter within the SeekBar.

If the thumb is a valid drawable (i.e. not null), half its width will be used as the new thumb offset (@see #setThumbOffset(int)).

Parameters
thumb Drawable representing the thumb

public void setThumbOffset (int thumbOffset)

Added in API level 1

Sets the thumb offset that allows the thumb to extend out of the range of the track.

Parameters
thumbOffset The offset amount in pixels.

public void setThumbTintList (ColorStateList tint)

Added in API level 21

Applies a tint to the thumb drawable. Does not modify the current tint mode, which is SRC_IN by default.

Subsequent calls to setThumb(Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using setTintList(ColorStateList).

Related XML Attributes
Parameters
tint the tint to apply, may be null to clear tint

public void setThumbTintMode (PorterDuff.Mode tintMode)

Added in API level 21

Specifies the blending mode used to apply the tint specified by setThumbTintList(ColorStateList)} to the thumb drawable. The default mode is SRC_IN.

Related XML Attributes
Parameters
tintMode the blending mode used to apply the tint, may be null to clear tint

Protected Methods

protected void drawableStateChanged ()

Added in API level 1

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.

protected synchronized void onDraw (Canvas canvas)

Added in API level 1

Implement this to do your drawing.

Parameters
canvas the canvas on which the background will be drawn

protected synchronized void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Added in API level 1

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

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

Added in API level 1

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w Current width of this view.
h Current height of this view.
oldw Old width of this view.
oldh Old height of this view.

protected boolean verifyDrawable (Drawable who)

Added in API level 1

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.

Parameters
who The Drawable to verify. Return true if it is one you are displaying, else return the result of calling through to the super class.
Returns
  • boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate.