我用动作条
的 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);
相关推荐
最新文章