0

In my application I have an activity thats layout is basicly following:

App layout

The red part is a viewpager with fragments. The blue part is a layout with buttons that doesnt change with swipe on viewpager. But i want that the viewpager is swipable (smoothly) in the hole green framed area. It should act like normal viewpager behavior.

I have absolutely no idea if that is even possible or not, but hope it does.

I thought that it is maybe possible with a gestureoverlay or something, but don't know how to apply the detected gesture on the viewpager. Only detecting swipe and set current page is not what I want achieve.

(I'm writing in java)

2 Answers2

0

If the height of the viewpager and buttons layout are somewhat fixed, here is a solution:

1, use a ConstraintLayout as the root container

2, make viewpager the same size as the root, set the viewpager's padding to some value say 8dp

3, place the buttons layout over the view pager, taking up the bottom half space(except for some margin), the viewpager should still respond to touch where there is no button

4, for fragments inside view pager, use a ConstraintLayout to put the content at the top half of the page

ssynhtn
  • 1,307
  • 12
  • 18
  • The problem is that the "blue" part is a layout with own background, that i am including. So the viewpager doesnt repond to touch/swipe from it – Blood_Working_ Jun 04 '19 at 16:27
  • it does. unless your background has its own touch/click handler, in which case the swipe/scroll shouldn't happen anyway – ssynhtn Jun 05 '19 at 01:49
0

I think this is what you are looking for Nested Action Bar Tabs(with ViewPager)

There's also a demo on Github: https://github.com/r3dm4n/NestedActionBarTabswithViewPagerDEMO Let me know if it helped

r3dm4n
  • 1,175
  • 2
  • 18
  • 33