ViewPagerIndicator

本博客介绍了一个与Android支持库和ActionBar Sherlock兼容的指示器库,用于指示ViewPager中的相邻页面。提供了五种样式,包括标题指示器、滚动动画选项卡指示器、圆形指示器、线条指示器和下划线指示器,帮助用户清晰地了解可以导航到的额外内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://viewpagerindicator.com/

Introduction

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock. Originally based on Patrik Å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 ZIP Download 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 the ViewPager it represents.
    <com.viewpagerindicator.TitlePageIndicator
    	android: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 the ViewPager.
    //Set the pager with an adapter
    ViewPager pager = (ViewPager)findViewById(R.id.pager);
    pager.setAdapter(new TestAdapter(getSupportFragmentManager()));
    
    //Bind the title indicator to the adapter
    TitlePageIndicator 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 above
    titleIndicator.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



### 回答1: ViewPagerIndicator是一个Android库,用于在ViewPager中添加指示器,以帮助用户了解当前页面的位置。它提供了多种指示器样式和自定义选项,可以轻松地与ViewPager集成。它是由Jake Wharton开发的,是一个广泛使用的库。 ### 回答2: ViewPagerIndicator是一个Android库,用于在ViewPager上添加标签指示器。它提供了一种简单而强大的方法来管理ViewPager的标签指示器,帮助用户在不同页面之间进行导航。该库是由Jake Wharton开发的,他是一位著名的Android程序员,也是Square公司的工程师。 使用ViewPagerIndicator可以为ViewPager添加多种类型的标签指示器,如圆形指示器、文字指示器、图片指示器等。你可以根据自己的需求选择合适的标签指示器样式,并自定义其外观和行为。该库支持水平和垂直方向的滑动,并兼容较旧的Android版本。 ViewPagerIndicator的使用非常简单,首先需要在项目中引入该库的依赖。然后,在布局文件中添加ViewPager和指示器,通过ViewPagerIndicator提供的适配器类将ViewPager和指示器绑定在一起。最后,你可以根据需要自定义指示器的样式、颜色等属性。 ViewPagerIndicator不仅提供了标签指示器,还包含其他一些有用的功能。例如,你可以通过ViewPagerIndicator轻松实现ViewPager的循环滚动,使第一页和最后一页之间实现无缝连接。此外,该库还支持自定义动画效果和触摸事件处理。 总之,ViewPagerIndicator是一个强大而灵活的Android库,为ViewPager添加标签指示器提供了便利。它可以帮助你更好地管理ViewPager的页面导航,并提供了丰富的自定义选项。无论是初学者还是有经验的Android开发者,都可以轻松地使用ViewPagerIndicator来改善用户界面的体验。 ### 回答3: ViewPagerIndicator是一个开源的视图指示器库,用于辅助在Android应用中实现ViewPager的指示器功能。它与ViewPager控件配合使用,为用户提供了一种方便的方式来切换页面,并显示当前页面的指示器。 ViewPagerIndicator的主要特点是简单易用和高度可定制。它提供了多种指示器样式,包括圆形、线性、文字等等,用户可以根据自己的需求选择合适的样式。同时,它还支持自定义指示器的颜色、大小、边距等属性,使用户可以完全控制指示器的外观。 除了基本的指示器功能之外,ViewPagerIndicator还提供了一些附加功能,如循环滚动、标题栏指示器等。循环滚动功能可以让用户在最后一个页面滑动时自动跳转到第一个页面,实现无限循环。标题栏指示器可以将指示器放置在标题栏上,使得用户可以在顶部直接切换页面,提升用户体验。 ViewPagerIndicator的使用也非常简单,只需要在项目中添加相应的依赖库,并在布局文件中配置指示器,然后在代码中设置ViewPager与指示器的关联即可。对于初学者来说,它是一个很好的学习资料,帮助他们快速地了解和使用ViewPager以及指示器的相关知识。 总而言之,ViewPagerIndicator是一个功能强大、简单易用的ViewPager指示器库,为开发者提供了丰富的样式和属性选择,帮助他们快速实现ViewPager的指示器功能,提升应用的用户体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值