13

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

Shaheen Zahedi
  • 1,216
  • 3
  • 15
  • 40

5 Answers5

5

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)

dzikovskyy
  • 5,027
  • 3
  • 32
  • 43
  • Also you can simply add an activity with BottomNavigationView using File > New > Activity > Bottom navigation activity. – CoolMind Dec 08 '17 at 14:59
3

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

btnTab.setTabChangeListener(null);
Chirag.T
  • 746
  • 1
  • 6
  • 18
1

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.

Community
  • 1
  • 1
Dimezis
  • 1,541
  • 11
  • 24
  • thanx for mentioning, but i've implemented Bottombar library and still, cannot get swipe action into fragment, what can I do? – Shaheen Zahedi Feb 28 '17 at 15:49
1

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!

Luís Gonçalves
  • 338
  • 5
  • 17
1

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

Meonix
  • 33
  • 6