How to implement horizontal scrolling / scrolling between fragments?

I would like to get navigation in my application, e.g. Pinterest or Trello, i.e. several three tabs for navigation + horizontal scrolling. I created a custom tab for this (because I couldnโ€™t figure out how to change the width of the tabs in my action bar with the TAB navigation mode). Therefore, I have three buttons to go from one fragment to another. Now I would like to use horizontal scrolling like these two examples to also navigate between my fragments. I read about View Pager, but I donโ€™t know if this is suitable for my business, since I have not only views, but fragments. Does anyone have an example or idea on how to do this? Can I apply it to various activities? Thanks

+4
source share
2 answers

Please take a look at the duplicate question I just answered:

How to implement swipe between fragments?

I believe Android ViewPager is what you are looking for:

http://developer.android.com/reference/android/support/v4/view/ViewPager.html

Here is a good tutorial on how to implement it:

http://developer.android.com/training/animation/screen-slide.html

The basic idea is that you have several fragments, each of which represents a different screen. . ViewPager allows the user to scroll between different fragments and display different content.

+5
source

You can use ViewPager. Additional information about viewpager this .

0
source

Source: https://habr.com/ru/post/1500320/


All Articles