public class

DotsPageIndicator

extends View
implements GridViewPager.OnPageChangeListener GridViewPager.OnAdapterChangeListener

Note: The Wearable Support Library classes under the android.support.wearable package are subject to change. For the full Android API reference, see Reference.

java.lang.Object
   ↳ android.view.View
     ↳ android.support.wearable.view.DotsPageIndicator

Class Overview

A page indicator for GridViewPager which identifies the current page in relation to all available pages on the current row. Pages are represented as dots. The current page can be highlighted with a different color or size dot.

The default behavior is to fade out the dots when the pager is idle (not settling or being dragged). This can be changed with setDotFadeWhenIdle(boolean).

Use setPager(GridViewPager) to connect this view to a pager instance.

Summary

[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
DotsPageIndicator(Context context)
DotsPageIndicator(Context context, AttributeSet attrs)
DotsPageIndicator(Context context, AttributeSet attrs, int defStyleAttr)
Public Methods
int getDotColor()
Returns the color used for dots other than the selected page.
int getDotColorSelected()
Returns the color of the dot for the selected page.
int getDotFadeInDuration()
Returns the duration of the fade in duration, in milliseconds.
int getDotFadeOutDelay()
Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.
int getDotFadeOutDuration()
Returns the duration of fade out animation, in milliseconds.
boolean getDotFadeWhenIdle()
Indicates if the dots fade out when the pager is idle.
float getDotRadius()
Gets the radius of the page dots.
float getDotRadiusSelected()
Gets the radius of the page dot for the selected page.
int getDotShadowColor()
Returns the color of the shadows drawn beneath the dots.
float getDotShadowDx()
Returns the horizontal offset of shadows drawn beneath the dots.
float getDotShadowDy()
Returns the vertical offset of shadows drawn beneath the dots.
float getDotShadowRadius()
Sets the pixel radius of shadows drawn beneath the dots.
float getDotSpacing()
Gets the center-to-center distance between page dots.
void onAdapterChanged(GridPagerAdapter oldAdapter, GridPagerAdapter newAdapter)
Called when the adapter is changed with setAdapter(GridPagerAdapter).
void onDataSetChanged()
Called when a change is made to the content of the current adapter.
void onPageScrollStateChanged(int state)
Called when the scroll state changes.
void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels)
This method will be invoked when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll.
void onPageSelected(int row, int column)
This method is called when a new page becomes selected.
void setDotColor(int color)
Sets the color used for dots other than the selected page.
void setDotColorSelected(int color)
Sets the color of the dot for the selected page.
void setDotFadeInDuration(int duration, TimeUnit unit)
Sets the duration of the fade in animation.
void setDotFadeOutDelay(int delay)
Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.
void setDotFadeOutDuration(int duration, TimeUnit unit)
Sets the duration of the fade out animation.
void setDotFadeWhenIdle(boolean fade)
Sets whether the dots fade out when the pager is idle.
void setDotRadius(int radius)
Sets the radius of the page dots.
void setDotRadiusSelected(int radius)
Sets the radius of the page dot for the selected page.
void setDotShadowColor(int color)
Sets the color of the shadows drawn beneath the dots.
void setDotShadowDx(float dx)
Sets the horizontal offset of shadows drawn beneath the dots.
void setDotShadowDy(float dy)
Sets the vertical offset of shadows drawn beneath the dots.
void setDotShadowRadius(float radius)
Sets the pixel radius of shadows drawn beneath the dots.
void setDotSpacing(int spacing)
Sets the center-to-center distance between page dots.
void setOnAdapterChangeListener(GridViewPager.OnAdapterChangeListener listener)
Sets a listener to receive the adapter change events that are provided to the page indicator.
void setOnPageChangeListener(GridViewPager.OnPageChangeListener listener)
Sets a listener to receive the page change events that are provided to the page indicator.
void setPager(GridViewPager pager)
Supplies the GridViewPager instance, and attaches this views GridViewPager.OnPageChangeListener and GridViewPager.OnAdapterChangeListener listeners to the pager.
Protected Methods
void onDraw(Canvas canvas)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
[Expand]
Inherited Methods
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
From interface android.support.wearable.view.GridViewPager.OnPageChangeListener
From interface android.support.wearable.view.GridViewPager.OnAdapterChangeListener

Public Constructors

public DotsPageIndicator (Context context)

public DotsPageIndicator (Context context, AttributeSet attrs)

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

Public Methods

public int getDotColor ()

Returns the color used for dots other than the selected page.

Returns
  • color the color used for dots other than the selected page

public int getDotColorSelected ()

Returns the color of the dot for the selected page.

Returns
  • the color used for the selected page dot

public int getDotFadeInDuration ()

Returns the duration of the fade in duration, in milliseconds.

Returns
  • the duration of the fade in duration, in milliseconds

public int getDotFadeOutDelay ()

Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.

Returns
  • the delay before the fade out animation begins, in milliseconds

public int getDotFadeOutDuration ()

Returns the duration of fade out animation, in milliseconds.

Returns
  • the duration of the fade out animation, in milliseconds

public boolean getDotFadeWhenIdle ()

Indicates if the dots fade out when the pager is idle.

Returns
  • whether the dots fade out when idle

public float getDotRadius ()

Gets the radius of the page dots.

Returns
  • the radius of the page dots

public float getDotRadiusSelected ()

Gets the radius of the page dot for the selected page.

Returns
  • the radius of the selected page dot

public int getDotShadowColor ()

Returns the color of the shadows drawn beneath the dots.

Returns
  • the color of the shadows drawn beneath the dots

public float getDotShadowDx ()

Returns the horizontal offset of shadows drawn beneath the dots.

Returns
  • the horizontal offset of shadows drawn beneath the dots

public float getDotShadowDy ()

Returns the vertical offset of shadows drawn beneath the dots.

Returns
  • the vertical offset of shadows drawn beneath the dots

public float getDotShadowRadius ()

Sets the pixel radius of shadows drawn beneath the dots.

Returns
  • the pixel radius of shadows rendered beneath the dots

public float getDotSpacing ()

Gets the center-to-center distance between page dots.

Returns
  • the distance between page dots

public void onAdapterChanged (GridPagerAdapter oldAdapter, GridPagerAdapter newAdapter)

Called when the adapter is changed with setAdapter(GridPagerAdapter).

public void onDataSetChanged ()

Called when a change is made to the content of the current adapter.

public void onPageScrollStateChanged (int state)

Called when the scroll state changes. Useful for discovering when the user begins dragging, when the pager is automatically settling to the current page, or when it is fully stopped/idle.

Parameters
state The new scroll state.

public void onPageScrolled (int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels)

This method will be invoked when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll.

Parameters
row Vertical position index of the new selected page row position+1 will be visible if positionOffset is nonzero
column Horizontal position index of the new selected page
rowOffset Value from [0, 1) indicating the offset from the row
columnOffset Value from [0, 1) indicating the offset from the column
rowOffsetPixels Value in pixels indicating the offset from row
columnOffsetPixels Value in pixels indicating the offset from column

public void onPageSelected (int row, int column)

This method is called when a new page becomes selected. The page may still be settling into final position.

Parameters
row Vertical position index of the new selected page
column Horizontal position index of the new selected page

public void setDotColor (int color)

Sets the color used for dots other than the selected page.

Parameters
color the color used for dots other than the selected page

public void setDotColorSelected (int color)

Sets the color of the dot for the selected page.

Parameters
color the color of the dot for the selected page

public void setDotFadeInDuration (int duration, TimeUnit unit)

Sets the duration of the fade in animation.

Parameters
duration the duration of the fade in animation

public void setDotFadeOutDelay (int delay)

Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.

Parameters
delay the delay before the fade out animation begins, in milliseconds

public void setDotFadeOutDuration (int duration, TimeUnit unit)

Sets the duration of the fade out animation.

Parameters
duration the duration of the fade out animation

public void setDotFadeWhenIdle (boolean fade)

Sets whether the dots fade out when the pager is idle.

Parameters
fade whether the dots fade out when idle

public void setDotRadius (int radius)

Sets the radius of the page dots.

Parameters
radius the radius of the page dots

public void setDotRadiusSelected (int radius)

Sets the radius of the page dot for the selected page.

Parameters
radius the radius of the selected page dot

public void setDotShadowColor (int color)

Sets the color of the shadows drawn beneath the dots.

Parameters
color the color of the shadows drawn beneath the dots

public void setDotShadowDx (float dx)

Sets the horizontal offset of shadows drawn beneath the dots.

Parameters
dx the horizontal offset of shadows drawn beneath the dots

public void setDotShadowDy (float dy)

Sets the vertical offset of shadows drawn beneath the dots.

Parameters
dy the vertical offset of shadows drawn beneath the dots

public void setDotShadowRadius (float radius)

Sets the pixel radius of shadows drawn beneath the dots.

Parameters
radius the pixel radius of shadows rendered beneath the dots

public void setDotSpacing (int spacing)

Sets the center-to-center distance between page dots.

Parameters
spacing the distance between page dots

public void setOnAdapterChangeListener (GridViewPager.OnAdapterChangeListener listener)

Sets a listener to receive the adapter change events that are provided to the page indicator. This allows an additional component to respond to these events without the need for additional code.

Parameters
listener the listener for adapter change events

public void setOnPageChangeListener (GridViewPager.OnPageChangeListener listener)

Sets a listener to receive the page change events that are provided to the page indicator. This allows an additional component to respond to these events without the need for additional code.

Parameters
listener the listener for page change events

public void setPager (GridViewPager pager)

Supplies the GridViewPager instance, and attaches this views GridViewPager.OnPageChangeListener and GridViewPager.OnAdapterChangeListener listeners to the pager.

Parameters
pager the pager for the page indicator

Protected Methods

protected void onDraw (Canvas canvas)

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)