public class

PageIndicator

extends View
java.lang.Object
   ↳ android.view.View
     ↳ greendroid.widget.PageIndicator

Class Overview

Visual indicator of a paged content. The PageIndicator usually displays a line of dots. Each dot represents a page. The PageIndicator supports two types of dots.

  • SINGLE: all dots are drawn but only one is in the selected state at a time. The selected one represents the currently visible page.
  • MULTIPLE: the selected page is actually represented by the amount of dots currently being drawn. This behavior is similar to the one visible on the Android Launcher application.

You can have a look at GDCatalog to get a sample code of how to use a PageIndicator in addition to a PagedView.

Summary

Nested Classes
interface PageIndicator.DotType Interface containing of dot types supported by the PageIndicator class. 
Constants
int NO_ACTIVE_DOT Constant that may be used to select none of the dots in the PageIndicator
[Expand]
Inherited Constants
From class android.view.View
Public Constructors
PageIndicator(Context context)
PageIndicator(Context context, AttributeSet attrs)
PageIndicator(Context context, AttributeSet attrs, int defStyle)
Public Methods
int getActiveDot()
Return the current active dot.
int getDotCount()
Get the maximum number of dots to be drawn.
Drawable getDotDrawable()
Return the Drawable currently used for each dot.
int getDotSpacing()
The spacing between each dot
int getDotType()
The current dot type
int getGravity()
Return the gravity used to draw dots/
void invalidate()
void onRestoreInstanceState(Parcelable state)
Parcelable onSaveInstanceState()
void requestLayout()
void setActiveDot(int activeDot)
Set the index of the active dot or the number of active dots.
void setDotCount(int dotCount)
Set the number of dots.
void setDotDrawable(Drawable dotDrawable)
Set the Drawable used for each dot.
void setDotSpacing(int dotSpacing)
Set the spacing between each dot
void setDotType(int dotType)
Specifies the type of dot actually drawn by this PageIndicator
void setGravity(int gravity)
Specifies how to align the dots by the view's x- and/or y-axis when the space taken by the dots is smaller than the view.
Protected Methods
void drawableStateChanged()
void onDraw(Canvas canvas)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
boolean verifyDrawable(Drawable who)
[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

Constants

public static final int NO_ACTIVE_DOT

Constant that may be used to select none of the dots in the PageIndicator

Constant Value: -1 (0xffffffff)

Public Constructors

public PageIndicator (Context context)

public PageIndicator (Context context, AttributeSet attrs)

public PageIndicator (Context context, AttributeSet attrs, int defStyle)

Public Methods

public int getActiveDot ()

Return the current active dot. Depending on the current dot type of this PageIndicator the current active dot may be the number of displayed dots or the index of the selected dot

Returns
  • The current active dot index or dots count

public int getDotCount ()

Get the maximum number of dots to be drawn.

Returns
  • The maximum number of dots.
See Also

public Drawable getDotDrawable ()

Return the Drawable currently used for each dot.

Returns
  • The Drawable used to draw each dot.

public int getDotSpacing ()

The spacing between each dot

Returns
  • The spacing between each dot

public int getDotType ()

The current dot type

Returns

public int getGravity ()

Return the gravity used to draw dots/

Returns
  • The current gravity

public void invalidate ()

public void onRestoreInstanceState (Parcelable state)

public Parcelable onSaveInstanceState ()

public void requestLayout ()

public void setActiveDot (int activeDot)

Set the index of the active dot or the number of active dots. Depending on the current dot type of this PageIndicator the current active dot may be the number of displayed dots or the index of the selected dot

Parameters
activeDot The number/index of (the) active dot(s)
See Also

public void setDotCount (int dotCount)

Set the number of dots.

Parameters
dotCount The number oF dots
See Also

public void setDotDrawable (Drawable dotDrawable)

Set the Drawable used for each dot. The given Drawable may be a StateListDrawable in order to take advantage of the selection system. If your StateListDrawable contains a android.R.attr.state_selected state, the Drawable will be used to represent a selected dot. Note : this methods does not support Drawable that has no intrinsic dimensions.

Parameters
dotDrawable The Drawable used to represents a dot

public void setDotSpacing (int dotSpacing)

Set the spacing between each dot

Parameters
dotSpacing The spacing between each dot.

public void setDotType (int dotType)

Specifies the type of dot actually drawn by this PageIndicator

Parameters
dotType The dot type to use

public void setGravity (int gravity)

Specifies how to align the dots by the view's x- and/or y-axis when the space taken by the dots is smaller than the view.

Parameters
gravity The gravity

Protected Methods

protected void drawableStateChanged ()

protected void onDraw (Canvas canvas)

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

protected boolean verifyDrawable (Drawable who)