在不更改视图的情况下在 PagerTabStrip 标题内导航?
Navigate inside PagerTabStrip titles without changing the views?
我想在大量视图之间导航,所以我用 PagerTabStrip 实现了 ViewPager。现在我希望能够在不更改视图的情况下从第一个标题转到最后一个标题,如果您注意到 PlayStore 已经实现的话。
PagerTabStrip 仅转到下一个或上一个标题并更改视图,因为我有很多视图,我发现它让用户感到厌烦。
我找到 XLPagerTabStrip for iOS,但找不到 android。
你可以利用PagerSlidingTabStrip,
For a working implementation of this project see the sample/ folder.
Include the library as local library project or add the dependency in
your build.gradle.
dependencies {
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
Include the PagerSlidingTabStrip widget in your layout. This should
usually be placed above the ViewPager it represents.
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dip" />
In your onCreate method (or onCreateView for a fragment), bind the
widget to the ViewPager.
// Initialize the ViewPager and set an adapter
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new TestAdapter(getSupportFragmentManager()));
// Bind the tabs to the ViewPager
PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
tabs.setViewPager(pager);
(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);
我想在大量视图之间导航,所以我用 PagerTabStrip 实现了 ViewPager。现在我希望能够在不更改视图的情况下从第一个标题转到最后一个标题,如果您注意到 PlayStore 已经实现的话。
PagerTabStrip 仅转到下一个或上一个标题并更改视图,因为我有很多视图,我发现它让用户感到厌烦。
我找到 XLPagerTabStrip for iOS,但找不到 android。
你可以利用PagerSlidingTabStrip,
For a working implementation of this project see the sample/ folder.
Include the library as local library project or add the dependency in your build.gradle.
dependencies { compile 'com.astuetz:pagerslidingtabstrip:1.0.1' }
Include the PagerSlidingTabStrip widget in your layout. This should usually be placed above the ViewPager it represents.
<com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="48dip" />
In your onCreate method (or onCreateView for a fragment), bind the widget to the ViewPager.
// Initialize the ViewPager and set an adapter ViewPager pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(new TestAdapter(getSupportFragmentManager())); // Bind the tabs to the ViewPager PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); tabs.setViewPager(pager);
(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);