动作条移动选项卡指示器 [英] Actionbar moving tab indicator

查看:145
本文介绍了动作条移动选项卡指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用动作条 AppCompact 有标签和 ViewPager
我怎样才能实现移动(与片段)的Onavo应用程序选项卡的指标是怎样的?
我试图用 PagerTitleStrip ,但没有成功。

I'm using ActionBar of AppCompact with tabs and ViewPager.
How can I implement moving (with the fragment) tabs indicator like in Onavo app?
I tried to use PagerTitleStrip but didn't succeed.

推荐答案

有一个名为PagerSlidingTabStrip库,它正是你想要的:的 https://github.com/astuetz/PagerSlidingTabStrip

There is a library called "PagerSlidingTabStrip" that does exactly what you want: https://github.com/astuetz/PagerSlidingTabStrip

交互式寻呼指示窗口小部件,与ViewPager从Android的支持库。

Interactive paging indicator widget, compatible with the ViewPager from the Android Support Library.

用法

附上PagerSlidingTabStrip小部件在您的视图。这通常应放在靠近它重新presents的ViewPager。

Include the PagerSlidingTabStrip widget in your view. This should usually be placed adjacent to the ViewPager it represents.

<com.astuetz.viewpager.extensions.PagerSlidingTabStrip
   android:id="@+id/tabs"
   android:layout_width="match_parent"
    android:layout_height="48dip" />

在您的onCreate方法(或onCreateView的片段),绑定控件到ViewPager。

In your onCreate method (or onCreateView for a fragment), bind the widget to the ViewPager.

 // Set the pager with an adapter
 ViewPager pager = (ViewPager) findViewById(R.id.pager);
 pager.setAdapter(new TestAdapter(getSupportFragmentManager()));

 // Bind the widget to the adapter
 PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
 tabs.setViewPager(pager);

(可选)如果您使用OnPageChangeListener你的看法寻呼机,你应该设置在窗口小部件,而不是直接在寻呼机。

(Optional) If you use an OnPageChangeListener with your view pager you should set it in the widget rather than on the pager directly.

 // continued from above
 tabs.setOnPageChangeListener(mPageChangeListener);

这篇关于动作条移动选项卡指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆