Search code examples
androidandroid-viewpagerswipe

Left-right arrow indicators over a ViewPager


I want to show left and right arrows over my ViewPager, to indicate swiping.

I added two ImageButtons over the ViewPager-element but those areas then block the ViewPager from triggering the "swiping".

I also want presses on those arrows to trigger the fragment to change accordingly.

In short: The ImageButtons should not interfere with swiping but they should register pressing.

How can I achieve this? Thanks!


Solution

  • Instead of using ImageButtons for displaying the arrows, I now use ImageViews because they pass on any touch events to the layer underneath.

    Then, I put transparent Buttons on the fragments themselves instead, that way they won't block the ViewPagers swiping behaviour but they will fire onClick Events!