Shaheen Zahedi
Shaheen Zahedi

Reputation: 1266

Nested tabs with viewpager swiping in android?

I've implemented nested tabs with view pager with no problems, but my problem is on the swiping part,

When I do the swiping action the main activity tabs will be switched, but I want the fragment to swipe instead. how can I achieve this?

I've tried implement main tab with tab host and fragment tabhost which doesn't have swiping feature at all, but that disabled whole swipe on the main and fragment together. Description

Upvotes: 13

Views: 1880

Answers (5)

Meonix
Meonix

Reputation: 33

I made a sample project with nested tab and fragment. may be it might help what is you looking for.

following link to download: NestedTabWithFragment

Upvotes: 1

dzikovskyy
dzikovskyy

Reputation: 5087

Instead of custom library you can try to use Bottom navigation view for bottom bar which has been added to version 25 of the Design Support Library. Here is an Article about it.

So android.support.design.widget.BottomNavigationViewin your activity together with android.support.design.widget.TabLayout and ViewPagerin fragment should work the way you want it to work. And this will also provide good UX (similar to one implemented in Google Plus App)

Upvotes: 5

I feel like it is wise to follow the Google Material guidelines. Not sure if you checked it out already...

Either way, here is what Google considers best practice for lateral navigation between tabs. Hope it helps!

Upvotes: 1

Dimezis
Dimezis

Reputation: 1595

You can disable view pager swiping on a particular ViewPager. But I would suggest to not make 2 ViewPagers on the same screen. Your bottom TabLayout and corresponding ViewPager can be replaced with BottomBar library.

Upvotes: 1

Chirag.T
Chirag.T

Reputation: 756

hello shaheen zahedi maybe it's possible please..with..below just set bottom tab changed listener like..

btnTab.setTabChangeListener(null);

Upvotes: 3

Related Questions