Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

PagedScrollBarView

public class PagedScrollBarView
extends ViewGroup

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.car.widget.PagedScrollBarView


A custom view to provide list scroll behaviour -- up/down buttons and scroll indicator.

Summary

Nested classes

interface PagedScrollBarView.PaginationListener

Listener for when the list should paginate. 

Inherited constants

Inherited fields

Public constructors

PagedScrollBarView(Context context)
PagedScrollBarView(Context context, AttributeSet attrs)
PagedScrollBarView(Context context, AttributeSet attrs, int defStyleAttrs)
PagedScrollBarView(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes)

Public methods

boolean isDownEnabled()

Returns whether or not the down button on the scroll bar is clickable.

boolean isDownPressed()

Returns true if the "down" button is pressed

boolean isScrollbarThumbEnabled()

Returns true if the scroll bar thumb is visible

boolean isUpPressed()

Returns true if the "up" button is pressed

void onLayout(boolean changed, int left, int top, int right, int bottom)
void setButtonRippleBackground(int backgroundResId)

Sets the drawable that will function as the background for the buttons in this view.

void setButtonTintColor(int tintResId)

Sets the tint color for the up and down buttons of this view.

void setDownButtonIcon(Drawable icon)

Sets the icon to be used for the down button.

void setDownEnabled(boolean enabled)

Sets whether or not the down button on the scroll bar is clickable.

void setPaginationListener(PagedScrollBarView.PaginationListener listener)

Sets the listener that will be notified when the up and down buttons have been pressed.

void setParameters(int range, int offset, int extent, boolean animate)

Sets the range, offset and extent of the scroll bar.

void setScrollbarThumbColor(int color)

Sets the color of thumb.

void setScrollbarThumbEnabled(boolean show)

Sets whether or not the scroll bar thumb is visible, the default value is true.

void setUpButtonIcon(Drawable icon)

Sets the icon to be used for the up button.

void setUpEnabled(boolean enabled)

Sets whether or not the up button on the scroll bar is clickable.

Protected methods

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited methods

Public constructors

PagedScrollBarView

public PagedScrollBarView (Context context)

Parameters
context Context

PagedScrollBarView

public PagedScrollBarView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

PagedScrollBarView

public PagedScrollBarView (Context context, 
                AttributeSet attrs, 
                int defStyleAttrs)

Parameters
context Context

attrs AttributeSet

defStyleAttrs int

PagedScrollBarView

public PagedScrollBarView (Context context, 
                AttributeSet attrs, 
                int defStyleAttrs, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttrs int

defStyleRes int

Public methods

isDownEnabled

public boolean isDownEnabled ()

Returns whether or not the down button on the scroll bar is clickable.

Returns
boolean true if the down button is enabled. false otherwise.

isDownPressed

public boolean isDownPressed ()

Returns true if the "down" button is pressed

Returns
boolean

isScrollbarThumbEnabled

public boolean isScrollbarThumbEnabled ()

Returns true if the scroll bar thumb is visible

Returns
boolean

isUpPressed

public boolean isUpPressed ()

Returns true if the "up" button is pressed

Returns
boolean

onLayout

public void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Parameters
changed boolean

left int

top int

right int

bottom int

setButtonRippleBackground

public void setButtonRippleBackground (int backgroundResId)

Sets the drawable that will function as the background for the buttons in this view. This background should provide the ripple.

Parameters
backgroundResId int: The drawable resource identifier for the ripple background.

setButtonTintColor

public void setButtonTintColor (int tintResId)

Sets the tint color for the up and down buttons of this view.

Parameters
tintResId int: Resource identifier of the tint color.

setDownButtonIcon

public void setDownButtonIcon (Drawable icon)

Sets the icon to be used for the down button.

Parameters
icon Drawable

setDownEnabled

public void setDownEnabled (boolean enabled)

Sets whether or not the down button on the scroll bar is clickable.

Parameters
enabled boolean: true if the down button is enabled.

setPaginationListener

public void setPaginationListener (PagedScrollBarView.PaginationListener listener)

Sets the listener that will be notified when the up and down buttons have been pressed.

Parameters
listener PagedScrollBarView.PaginationListener: The listener to set.

setParameters

public void setParameters (int range, 
                int offset, 
                int extent, 
                boolean animate)

Sets the range, offset and extent of the scroll bar. The range represents the size of a container for the scrollbar thumb; offset is the distance from the start of the container to where the thumb should be; and finally, extent is the size of the thumb.

These values can be expressed in arbitrary units, so long as they share the same units. The values should also be positive.

Parameters
range int: The range of the scrollbar's thumb

offset int: The offset of the scrollbar's thumb

extent int: The extent of the scrollbar's thumb

animate boolean: Whether or not the thumb should animate from its current position to the position specified by the given range, offset and extent.

setScrollbarThumbColor

public void setScrollbarThumbColor (int color)

Sets the color of thumb.

Parameters
color int: Resource identifier of the color.

setScrollbarThumbEnabled

public void setScrollbarThumbEnabled (boolean show)

Sets whether or not the scroll bar thumb is visible, the default value is true.

Parameters
show boolean: true if the scroll bar thumb is visible.

setUpButtonIcon

public void setUpButtonIcon (Drawable icon)

Sets the icon to be used for the up button.

Parameters
icon Drawable

setUpEnabled

public void setUpEnabled (boolean enabled)

Sets whether or not the up button on the scroll bar is clickable.

Parameters
enabled boolean: true if the up button is enabled.

Protected methods

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int