com.viewpagerindicator
Class TitlePageIndicator

java.lang.Object
  extended by android.view.View
      extended by com.viewpagerindicator.TitlePageIndicator
All Implemented Interfaces:
android.graphics.drawable.Drawable.Callback, android.support.v4.view.ViewPager.OnPageChangeListener, android.view.accessibility.AccessibilityEventSource, android.view.KeyEvent.Callback, PageIndicator

public class TitlePageIndicator
extends android.view.View
implements PageIndicator

A TitlePageIndicator is a PageIndicator which displays the title of left view (if exist), the title of the current select view (centered) and the title of the right view (if exist). When the user scrolls the ViewPager then titles are also scrolled.


Nested Class Summary
static class TitlePageIndicator.IndicatorStyle
           
static interface TitlePageIndicator.OnCenterItemClickListener
          Interface for a callback when the center item has been clicked.
 
Nested classes/interfaces inherited from class android.view.View
android.view.View.BaseSavedState, android.view.View.MeasureSpec, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnFocusChangeListener, android.view.View.OnKeyListener, android.view.View.OnLongClickListener, android.view.View.OnTouchListener
 
Field Summary
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
TitlePageIndicator(android.content.Context context)
           
TitlePageIndicator(android.content.Context context, android.util.AttributeSet attrs)
           
TitlePageIndicator(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
           
 
Method Summary
 float getClipPadding()
           
 int getFooterColor()
           
 float getFooterIndicatorHeight()
           
 float getFooterIndicatorPadding()
           
 TitlePageIndicator.IndicatorStyle getFooterIndicatorStyle()
           
 float getFooterLineHeight()
           
 int getSelectedColor()
           
 int getTextColor()
           
 float getTextSize()
           
 float getTitlePadding()
           
 float getTopPadding()
           
 android.graphics.Typeface getTypeface()
           
 boolean isSelectedBold()
           
 void notifyDataSetChanged()
          Notify the indicator that the fragment list has changed.
protected  void onDraw(android.graphics.Canvas canvas)
           
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           
 void onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
           
 void onPageScrollStateChanged(int state)
           
 void onPageSelected(int position)
           
 void onRestoreInstanceState(android.os.Parcelable state)
           
 android.os.Parcelable onSaveInstanceState()
           
 boolean onTouchEvent(android.view.MotionEvent ev)
           
 void setClipPadding(float clipPadding)
           
 void setCurrentItem(int item)
          Set the current page of both the ViewPager and indicator.
 void setFooterColor(int footerColor)
           
 void setFooterIndicatorHeight(float footerTriangleHeight)
           
 void setFooterIndicatorPadding(float footerIndicatorPadding)
           
 void setFooterIndicatorStyle(TitlePageIndicator.IndicatorStyle indicatorStyle)
           
 void setFooterLineHeight(float footerLineHeight)
           
 void setOnCenterItemClickListener(TitlePageIndicator.OnCenterItemClickListener listener)
          Set a callback listener for the center item click.
 void setOnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener listener)
          Set a page change listener which will receive forwarded events.
 void setSelectedBold(boolean selectedBold)
           
 void setSelectedColor(int selectedColor)
           
 void setTextColor(int textColor)
           
 void setTextSize(float textSize)
           
 void setTitlePadding(float titlePadding)
           
 void setTopPadding(float topPadding)
           
 void setTypeface(android.graphics.Typeface typeface)
           
 void setViewPager(android.support.v4.view.ViewPager view)
          Bind the indicator to a ViewPager.
 void setViewPager(android.support.v4.view.ViewPager view, int initialPosition)
          Bind the indicator to a ViewPager.
 
Methods inherited from class android.view.View
addFocusables, addFocusables, addTouchables, bringToFront, buildDrawingCache, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, clearFocus, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, destroyDrawingCache, dispatchDraw, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, draw, drawableStateChanged, finalize, findFocus, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTag, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasFocus, hasFocusable, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isPaddingOffsetRequired, isPressed, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onAttachedToWindow, onCheckIsTextEditor, onCreateContextMenu, onCreateDrawableState, onCreateInputConnection, onDetachedFromWindow, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onKeyDown, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPadding, setPressed, setSaveEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setTag, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TitlePageIndicator

public TitlePageIndicator(android.content.Context context)

TitlePageIndicator

public TitlePageIndicator(android.content.Context context,
                          android.util.AttributeSet attrs)

TitlePageIndicator

public TitlePageIndicator(android.content.Context context,
                          android.util.AttributeSet attrs,
                          int defStyle)
Method Detail

getFooterColor

public int getFooterColor()

setFooterColor

public void setFooterColor(int footerColor)

getFooterLineHeight

public float getFooterLineHeight()

setFooterLineHeight

public void setFooterLineHeight(float footerLineHeight)

getFooterIndicatorHeight

public float getFooterIndicatorHeight()

setFooterIndicatorHeight

public void setFooterIndicatorHeight(float footerTriangleHeight)

getFooterIndicatorPadding

public float getFooterIndicatorPadding()

setFooterIndicatorPadding

public void setFooterIndicatorPadding(float footerIndicatorPadding)

getFooterIndicatorStyle

public TitlePageIndicator.IndicatorStyle getFooterIndicatorStyle()

setFooterIndicatorStyle

public void setFooterIndicatorStyle(TitlePageIndicator.IndicatorStyle indicatorStyle)

getSelectedColor

public int getSelectedColor()

setSelectedColor

public void setSelectedColor(int selectedColor)

isSelectedBold

public boolean isSelectedBold()

setSelectedBold

public void setSelectedBold(boolean selectedBold)

getTextColor

public int getTextColor()

setTextColor

public void setTextColor(int textColor)

getTextSize

public float getTextSize()

setTextSize

public void setTextSize(float textSize)

getTitlePadding

public float getTitlePadding()

setTitlePadding

public void setTitlePadding(float titlePadding)

getTopPadding

public float getTopPadding()

setTopPadding

public void setTopPadding(float topPadding)

getClipPadding

public float getClipPadding()

setClipPadding

public void setClipPadding(float clipPadding)

setTypeface

public void setTypeface(android.graphics.Typeface typeface)

getTypeface

public android.graphics.Typeface getTypeface()

onDraw

protected void onDraw(android.graphics.Canvas canvas)
Overrides:
onDraw in class android.view.View

onTouchEvent

public boolean onTouchEvent(android.view.MotionEvent ev)
Overrides:
onTouchEvent in class android.view.View

setViewPager

public void setViewPager(android.support.v4.view.ViewPager view)
Description copied from interface: PageIndicator
Bind the indicator to a ViewPager.

Specified by:
setViewPager in interface PageIndicator

setViewPager

public void setViewPager(android.support.v4.view.ViewPager view,
                         int initialPosition)
Description copied from interface: PageIndicator
Bind the indicator to a ViewPager.

Specified by:
setViewPager in interface PageIndicator

notifyDataSetChanged

public void notifyDataSetChanged()
Description copied from interface: PageIndicator
Notify the indicator that the fragment list has changed.

Specified by:
notifyDataSetChanged in interface PageIndicator

setOnCenterItemClickListener

public void setOnCenterItemClickListener(TitlePageIndicator.OnCenterItemClickListener listener)
Set a callback listener for the center item click.

Parameters:
listener - Callback instance.

setCurrentItem

public void setCurrentItem(int item)
Description copied from interface: PageIndicator

Set the current page of both the ViewPager and indicator.

This must be used if you need to set the page before the views are drawn on screen (e.g., default start page).

Specified by:
setCurrentItem in interface PageIndicator

onPageScrollStateChanged

public void onPageScrollStateChanged(int state)
Specified by:
onPageScrollStateChanged in interface android.support.v4.view.ViewPager.OnPageChangeListener

onPageScrolled

public void onPageScrolled(int position,
                           float positionOffset,
                           int positionOffsetPixels)
Specified by:
onPageScrolled in interface android.support.v4.view.ViewPager.OnPageChangeListener

onPageSelected

public void onPageSelected(int position)
Specified by:
onPageSelected in interface android.support.v4.view.ViewPager.OnPageChangeListener

setOnPageChangeListener

public void setOnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener listener)
Description copied from interface: PageIndicator
Set a page change listener which will receive forwarded events.

Specified by:
setOnPageChangeListener in interface PageIndicator

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Overrides:
onMeasure in class android.view.View

onRestoreInstanceState

public void onRestoreInstanceState(android.os.Parcelable state)
Overrides:
onRestoreInstanceState in class android.view.View

onSaveInstanceState

public android.os.Parcelable onSaveInstanceState()
Overrides:
onSaveInstanceState in class android.view.View


Copyright © 2011-2012 Jake Wharton. All Rights Reserved.