Class AbsSeekBar

All Implemented Interfaces:
Drawable.Callback
Direct Known Subclasses:
SeekBar

public abstract class AbsSeekBar extends ProgressBar
  • Constructor Details

    • AbsSeekBar

      public AbsSeekBar(Context context)
  • Method Details

    • setThumb

      public void setThumb(Drawable thumb)
      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
    • getThumb

      public 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.
      Returns:
      The current thumb drawable
    • setThumbTintList

      public void setThumbTintList(@Nullable ColorStateList tint)
      Applies a tint to the thumb drawable.

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

      Parameters:
      tint - the tint to apply, may be null to clear tint
      See Also:
    • getThumbTintList

      @Nullable public ColorStateList getThumbTintList()
      Returns the tint applied to the thumb drawable, if specified.
      Returns:
      the tint applied to the thumb drawable
      See Also:
    • setThumbTintBlendMode

      public void setThumbTintBlendMode(@Nullable BlendMode blendMode)
      Specifies the blending mode used to apply the tint specified by setThumbTintList(ColorStateList)} to the thumb drawable. The default mode is BlendMode.SRC_IN.
      Parameters:
      blendMode - the blending mode used to apply the tint, may be null to clear tint
      See Also:
    • getThumbTintBlendMode

      @Nullable public BlendMode getThumbTintBlendMode()
      Returns the blending mode used to apply the tint to the thumb drawable, if specified.
      Returns:
      the blending mode used to apply the tint to the thumb drawable
      See Also:
    • getThumbOffset

      public int getThumbOffset()
      See Also:
    • setThumbOffset

      public void setThumbOffset(int thumbOffset)
      Sets the thumb offset that allows the thumb to extend out of the range of the track.
      Parameters:
      thumbOffset - The offset amount in pixels.
    • setSplitTrack

      public void setSplitTrack(boolean splitTrack)
      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
    • getSplitTrack

      public boolean getSplitTrack()
      Returns whether the track should be split by the thumb.
    • setTickMark

      public void setTickMark(Drawable tickMark)
      Sets the drawable displayed at each progress position, e.g. at each possible thumb position.
      Parameters:
      tickMark - the drawable to display at each progress position
    • getTickMark

      public Drawable getTickMark()
      Returns:
      the drawable displayed at each progress position
    • setTickMarkTintList

      public void setTickMarkTintList(@Nullable ColorStateList tint)
      Applies a tint to the tick mark drawable.

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

      Parameters:
      tint - the tint to apply, may be null to clear tint
      See Also:
    • getTickMarkTintList

      @Nullable public ColorStateList getTickMarkTintList()
      Returns the tint applied to the tick mark drawable, if specified.
      Returns:
      the tint applied to the tick mark drawable
      See Also:
    • setTickMarkTintBlendMode

      public void setTickMarkTintBlendMode(@Nullable BlendMode blendMode)
      Specifies the blending mode used to apply the tint specified by setTickMarkTintList(ColorStateList)} to the tick mark drawable. The default mode is BlendMode.SRC_IN.
      Parameters:
      blendMode - the blending mode used to apply the tint, may be null to clear tint
      See Also:
    • getTickMarkTintBlendMode

      @Nullable public BlendMode getTickMarkTintBlendMode()
      Returns the blending mode used to apply the tint to the tick mark drawable, if specified.
      Returns:
      the blending mode used to apply the tint to the tick mark drawable
    • setKeyProgressIncrement

      public void setKeyProgressIncrement(int increment)
      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.
    • getKeyProgressIncrement

      public int getKeyProgressIncrement()
      Returns the amount of progress changed via the arrow keys.

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

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

      protected boolean verifyDrawable(@NonNull Drawable who)
      Description copied from class: View
      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.

      Overrides:
      verifyDrawable in class ProgressBar
      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 then the Drawable is being displayed in the view; else false and it is not allowed to animate.
      See Also:
    • jumpDrawablesToCurrentState

      public void jumpDrawablesToCurrentState()
      Description copied from class: View
      Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

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

      Overrides:
      jumpDrawablesToCurrentState in class ProgressBar
    • drawableStateChanged

      protected void drawableStateChanged()
      Description copied from class: View
      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.

      Overrides:
      drawableStateChanged in class ProgressBar
      See Also:
    • drawableHotspotChanged

      public void drawableHotspotChanged(float x, float y)
      Description copied from class: View
      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 View.dispatchDrawableHotspotChanged(float, float).

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

      Overrides:
      drawableHotspotChanged in class ProgressBar
      Parameters:
      x - hotspot x coordinate
      y - hotspot y coordinate
    • onSizeChanged

      protected void onSizeChanged(int w, int h, int oldw, int oldh)
      Description copied from class: View
      Called when width or height changed
      Overrides:
      onSizeChanged in class ProgressBar
      Parameters:
      w - new width
      h - new height
      oldw - previous width
      oldh - previous height
    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      Description copied from class: View
      Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

      CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling super.onMeasure() 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 the base one to provide better measurements of their content.

      Overrides:
      onMeasure in class ProgressBar
      Parameters:
      widthMeasureSpec - width measure specification imposed by the parent MeasureSpec
      heightMeasureSpec - height measure specification imposed by the parent MeasureSpec
    • onDraw

      protected void onDraw(@NonNull Canvas canvas)
      Description copied from class: View
      Draw the content of this view, implement this to do your drawing.

      Note that (0, 0) will be the top left of the bounds, and (width, height) will be the bottom right of the bounds.

      Overrides:
      onDraw in class ProgressBar
      Parameters:
      canvas - the canvas to draw content
    • drawTickMarks

      protected void drawTickMarks(Canvas canvas)
    • onTouchEvent

      public boolean onTouchEvent(@NonNull MotionEvent event)
      Description copied from class: View
      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 View.performClick(). This will ensure consistent system behavior.

      Overrides:
      onTouchEvent in class View
      Parameters:
      event - the touch event
      Returns:
      true if the event was handled by the view, false otherwise
    • onKeyDown

      public boolean onKeyDown(int keyCode, @NonNull KeyEvent event)
      Description copied from class: View
      Default implementation: perform press of the view when KeyEvent.KEY_ENTER, KeyEvent.KEY_KP_ENTER or KeyEvent.KEY_SPACE is released, if the view is enabled and clickable.
      Overrides:
      onKeyDown in class View
      Parameters:
      keyCode - a key code that represents the button pressed, from KeyEvent
      event - the KeyEvent object that defines the button action
    • onRtlPropertiesChanged

      public void onRtlPropertiesChanged(int layoutDirection)
      Description copied from class: View
      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.

      Overrides:
      onRtlPropertiesChanged in class View
      Parameters:
      layoutDirection - the direction of the layout
      See Also: