ViewPagerIndicator

来源:互联网 发布:淘宝中的电子商务 编辑:程序博客网 时间:2024/05/16 00:32

http://viewpagerindicator.com/

Introduction

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock. Originally based onPatrik Åkerfeldt's ViewFlow.

When using the ViewPager widget it is not always obvious to the user that there are adjacent views they can navigate to. By implementing this widget you provide a clear indicator that there exists additional content which they can click or swipe to see.

At present there are five styles of indicators which can be used:

Title Indicator

Displays the title of the selected page in the center with the titles of the adjacent pages (if available) in a more subtle style.

Title indicator sample screenshot
Tab Indicator

Similar to the title indicator but displays as many titles as possible in scrolling and animated horizontal tabs.

Tab indicator sample screenshot
Circle Indicator

Simple indication of the number of pages available in the pager with a separate drawing style for the currently selected page.

Circle indicator sample screenshot
Line Indicator

Similar to the circle indicator but draws a very subtle line for each page with a separate drawing style for the current page.

Underline Indicator

Mimics the indicator on the Ice Cream Sandwich application launcher with a fading line the moves with each page.

Download

Version 2.3.1 — 2012-05-19

Download ZIPDownload TGZ

Change Log

  • New LinePageIndicator! Draws small indicators lines much like the circle indicator but much more subtle.
  • New UnderlinePageIndicator! Acts like the indicator on the Ice Cream Sandwich application launcher.
  • Circle indicator now uses android:orientation rather than custom attribute.
  • Title indicator adapter callback now uses the standard getPageTitle(int) method introduced in the r6 version of the support library.
  • Title indicator now uses android:textSize and android:textColor in its styles.
  • Fix: Do not create objects in drawing, layout, or measurement steps of each indicator.
  • Fix: Improve offset detection when page margins are in use on the pager.
  • Maven: The dependency on the support library is now using an artifact from central rather than requiring you to deploy your own locally

Looking for an older version? Check here.

Try out the sample application: Download from the Android Market

Usage

  1. Include one of the widgets in your view. This should usually be placed adjacent to theViewPager it represents.
    <com.viewpagerindicator.TitlePageIndicatorandroid:id="@+id/titles"android:layout_height="wrap_content"android:layout_width="fill_parent" />
  2. In your onCreate method (or onCreateView for a fragment), bind the indicator to theViewPager.
    //Set the pager with an adapterViewPager pager = (ViewPager)findViewById(R.id.pager);pager.setAdapter(new TestAdapter(getSupportFragmentManager()));//Bind the title indicator to the adapterTitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.titles);titleIndicator.setViewPager(pager);
  3. (Optional) If you use an OnPageChangeListener with your view pager you should set it in the indicator rather than on the pager directly.
    //continued from abovetitleIndicator.setOnPageChangeListener(mPageChangeListener);

For more examples please take a look at the source code to the samples.

Implementations

Beautiful Widgets

Beautiful set of Widgets containing clock widget, clock and weather widget, weather widgets, date widgets and toggle widgets with skins/themes support! Now with more widgets and layouts!

FriendCaster

FriendCaster for Facebook gives you the best Facebook experience on Android devices!

SeriesGuide

Manage the progress of (re-)watching your favorite TV shows. Keep track of which episodes you still have to watch or which ones are upcoming.

Ride Metra

Ride Metra is an easy to use and beautiful transit app that provides Metra train schedules, station locations and directions, nearby stations, upcoming departures, Metra service advisory alerts and the ability to search for a Metra rail line or station.

Traktoid

Traktoid, a trakt client.

RateBeer for Android

Mobile interface to the world's largest source for information on craft beer: RateBeer.

Astronomy Picture of the Day

Get the latest pictures from NASA's Astronomy Picture of the Day (APOD) and set them as your homescreen wallpaper.

Notification Agenda

Simple application which turns small notes into pleasing status bar notifications with fancy high quality icons. All your notes are easily accessible so you never forget all those important appointments ever again.

BGSU News

Simplistic application that allows the user to view the most recent (university-approved) going-ons at Bowling Green State University.

Is your app missing?

Contact Jake Wharton or fork the project, update this page, and send a pull request!

Hint: It's in the gh-pages branch.

Credits

© 2011 Jake Wharton — @JakeWharton ·+JakeWharton

Developed and distributed under the Apache License, Version 2.0.

Originally based on widgets developed by Patrik Åkerfeldt.

Fork this project on GitHub