DotsPageIndicator

public class DotsPageIndicator
extends View implements GridViewPager.OnPageChangeListener, GridViewPager.OnAdapterChangeListener

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


GridViewPager的页面指示符,用于标识当前页面与当前行上所有可用页面的关系。 页面用点表示。 当前页面可以用不同的颜色或大小点高亮显示。

默认行为是在寻呼机空闲时(不稳定或被拖动)淡出点。 这可以通过setDotFadeWhenIdle(boolean)进行更改。

使用 setPager(GridViewPager)将此视图连接到寻呼机实例。

Summary

Inherited constants

From class android.view.View

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()

返回用于选定页面以外的点的颜色。

int getDotColorSelected()

返回所选页面的点的颜色。

int getDotFadeInDuration()

返回淡入持续时间的持续时间,以毫秒为单位。

int getDotFadeOutDelay()

设置寻呼机到达空闲状态的延迟时间,以及以毫秒为单位的淡出动画开始时间。

int getDotFadeOutDuration()

返回淡出动画的持续时间,以毫秒为单位。

boolean getDotFadeWhenIdle()

指示寻呼机闲置时点是否淡出。

float getDotRadius()

获取页面点的半径。

float getDotRadiusSelected()

获取所选页面的页面点的半径。

int getDotShadowColor()

返回点之下绘制的阴影的颜色。

float getDotShadowDx()

返回在点之下绘制的阴影的水平偏移。

float getDotShadowDy()

返回在点之下绘制的阴影的垂直偏移量。

float getDotShadowRadius()

设置在点下绘制的阴影的像素半径。

float getDotSpacing()

获取页面点之间的中心到中心的距离。

void onAdapterChanged(GridPagerAdapter oldAdapter, GridPagerAdapter newAdapter)

当适配器更改为 setAdapter(GridPagerAdapter)时调用。

void onDataSetChanged()

当更改当前适配器的内容时调用。

void onPageScrollStateChanged(int state)

当滚动状态改变时调用。

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

此方法将在当前页面滚动时调用,或者作为程序启动的平滑滚动的一部分或用户启动的触摸滚动。

void onPageSelected(int row, int column)

当选择新页面时调用此方法。

void setDotColor(int color)

设置用于选定页面以外的点的颜色。

void setDotColorSelected(int color)

设置所选页面的点的颜色。

void setDotFadeInDuration(int duration, TimeUnit unit)

设置动画淡入淡出的持续时间。

void setDotFadeOutDelay(int delay)

设置寻呼机到达空闲状态的延迟时间,以及以毫秒为单位的淡出动画开始时间。

void setDotFadeOutDuration(int duration, TimeUnit unit)

设置淡出动画的持续时间。

void setDotFadeWhenIdle(boolean fade)

设置寻呼机空闲时点是否淡出。

void setDotRadius(int radius)

设置页面点的半径。

void setDotRadiusSelected(int radius)

设置所选页面的页面点的半径。

void setDotShadowColor(int color)

设置点之下绘制的阴影的颜色。

void setDotShadowDx(float dx)

设置点之下绘制的阴影的水平偏移。

void setDotShadowDy(float dy)

设置在点下绘制的阴影的垂直偏移。

void setDotShadowRadius(float radius)

设置在点下绘制的阴影的像素半径。

void setDotSpacing(int spacing)

设置页面点之间的中心距。

void setOnAdapterChangeListener(GridViewPager.OnAdapterChangeListener listener)

设置侦听器以接收提供给页面指示符的适配器更改事件。

void setOnPageChangeListener(GridViewPager.OnPageChangeListener listener)

设置侦听器以接收提供给页面指示符的页面更改事件。

void setPager(GridViewPager pager)

提供GridViewPager实例,并将此视图 GridViewPager.OnPageChangeListenerGridViewPager.OnAdapterChangeListener监听器附加到寻呼机。

Protected methods

void onDraw(Canvas canvas)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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

DotsPageIndicator

DotsPageIndicator (Context context)

Parameters
context Context

DotsPageIndicator

DotsPageIndicator (Context context,
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

DotsPageIndicator

DotsPageIndicator (Context context,
                AttributeSet attrs,
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

Public methods

getDotColor

int getDotColor ()

返回用于选定页面以外的点的颜色。

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

getDotColorSelected

int getDotColorSelected ()

返回所选页面的点的颜色。

Returns
int the color used for the selected page dot

getDotFadeInDuration

int getDotFadeInDuration ()

返回淡入持续时间的持续时间,以毫秒为单位。

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

getDotFadeOutDelay

int getDotFadeOutDelay ()

设置寻呼机到达空闲状态的延迟时间,以及以毫秒为单位的淡出动画开始时间。

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

getDotFadeOutDuration

int getDotFadeOutDuration ()

返回淡出动画的持续时间,以毫秒为单位。

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

getDotFadeWhenIdle

boolean getDotFadeWhenIdle ()

指示寻呼机闲置时点是否淡出。

Returns
boolean whether the dots fade out when idle

getDotRadius

float getDotRadius ()

获取页面点的半径。

Returns
float the radius of the page dots

getDotRadiusSelected

float getDotRadiusSelected ()

获取所选页面的页面点的半径。

Returns
float the radius of the selected page dot

getDotShadowColor

int getDotShadowColor ()

返回点之下绘制的阴影的颜色。

Returns
int the color of the shadows drawn beneath the dots

getDotShadowDx

float getDotShadowDx ()

返回在点之下绘制的阴影的水平偏移。

Returns
float the horizontal offset of shadows drawn beneath the dots

getDotShadowDy

float getDotShadowDy ()

返回在点之下绘制的阴影的垂直偏移量。

Returns
float the vertical offset of shadows drawn beneath the dots

getDotShadowRadius

float getDotShadowRadius ()

设置在点下绘制的阴影的像素半径。

Returns
float the pixel radius of shadows rendered beneath the dots

getDotSpacing

float getDotSpacing ()

获取页面点之间的中心到中心的距离。

Returns
float the distance between page dots

onAdapterChanged

void onAdapterChanged (GridPagerAdapter oldAdapter,
                GridPagerAdapter newAdapter)

当适配器更改为 setAdapter(GridPagerAdapter)时调用。

Parameters
oldAdapter GridPagerAdapter
newAdapter GridPagerAdapter

onDataSetChanged

void onDataSetChanged ()

当更改当前适配器的内容时调用。

onPageScrollStateChanged

void onPageScrollStateChanged (int state)

当滚动状态改变时调用。 用于发现用户何时开始拖动,何时寻呼机自动调整到当前页面,或何时完全停止/空闲。

Parameters
state int: The new scroll state.

onPageScrolled

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

此方法将在当前页面滚动时调用,或者作为程序启动的平滑滚动的一部分或用户启动的触摸滚动。

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

onPageSelected

void onPageSelected (int row,
                int column)

当选择新页面时调用此方法。 该页面可能仍然处于最终位置。

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

setDotColor

void setDotColor (int color)

设置用于选定页面以外的点的颜色。

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

setDotColorSelected

void setDotColorSelected (int color)

设置所选页面的点的颜色。

Parameters
color int: the color of the dot for the selected page

setDotFadeInDuration

void setDotFadeInDuration (int duration,
                TimeUnit unit)

设置动画淡入淡出的持续时间。

Parameters
duration int: the duration of the fade in animation
unit TimeUnit

setDotFadeOutDelay

void setDotFadeOutDelay (int delay)

设置寻呼机到达空闲状态的延迟时间,以及以毫秒为单位的淡出动画开始时间。

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

setDotFadeOutDuration

void setDotFadeOutDuration (int duration,
                TimeUnit unit)

设置淡出动画的持续时间。

Parameters
duration int: the duration of the fade out animation
unit TimeUnit

setDotFadeWhenIdle

void setDotFadeWhenIdle (boolean fade)

设置寻呼机空闲时点是否淡出。

Parameters
fade boolean: whether the dots fade out when idle

setDotRadius

void setDotRadius (int radius)

设置页面点的半径。

Parameters
radius int: the radius of the page dots

setDotRadiusSelected

void setDotRadiusSelected (int radius)

设置所选页面的页面点的半径。

Parameters
radius int: the radius of the selected page dot

setDotShadowColor

void setDotShadowColor (int color)

设置点之下绘制的阴影的颜色。

Parameters
color int: the color of the shadows drawn beneath the dots

setDotShadowDx

void setDotShadowDx (float dx)

设置点之下绘制的阴影的水平偏移。

Parameters
dx float: the horizontal offset of shadows drawn beneath the dots

setDotShadowDy

void setDotShadowDy (float dy)

设置在点下绘制的阴影的垂直偏移。

Parameters
dy float: the vertical offset of shadows drawn beneath the dots

setDotShadowRadius

void setDotShadowRadius (float radius)

设置在点下绘制的阴影的像素半径。

Parameters
radius float: the pixel radius of shadows rendered beneath the dots

setDotSpacing

void setDotSpacing (int spacing)

设置页面点之间的中心距。

Parameters
spacing int: the distance between page dots

setOnAdapterChangeListener

void setOnAdapterChangeListener (GridViewPager.OnAdapterChangeListener listener)

设置侦听器以接收提供给页面指示符的适配器更改事件。 这允许额外的组件响应这些事件而不需要额外的代码。

Parameters
listener GridViewPager.OnAdapterChangeListener: the listener for adapter change events

setOnPageChangeListener

void setOnPageChangeListener (GridViewPager.OnPageChangeListener listener)

设置侦听器以接收提供给页面指示符的页面更改事件。 这允许额外的组件响应这些事件而不需要额外的代码。

Parameters
listener GridViewPager.OnPageChangeListener: the listener for page change events

setPager

void setPager (GridViewPager pager)

提供GridViewPager实例,并将此视图 GridViewPager.OnPageChangeListenerGridViewPager.OnAdapterChangeListener监听器附加到寻呼机。

Parameters
pager GridViewPager: the pager for the page indicator

Protected methods

onDraw

void onDraw (Canvas canvas)

Parameters
canvas Canvas

onMeasure

void onMeasure (int widthMeasureSpec,
                int heightMeasureSpec)

Parameters
widthMeasureSpec int
heightMeasureSpec int