Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a horizontal scroll / swipe between Fragments?

I would like to achieve a navigation in my app like Pinterest or Trello, that is, kind of three tabs to navigation + horizontal scrolling. I have made a custom tabbar for this (since I couldn't guess how to change tabs width in my actionbar with navigation TAB mode). So I have three buttons to navigate from one fragment to another. Now I would like to implement the horizontal scrolling like these two examples, to also navigate among my fragments. I have read about View Pager but I don't know if it fits to my case, since I don't have only views but fragments. Does anybody have an example or an idea of how to do it? Could I apply it among different activities? Thanks

like image 441
DroidBeginner Avatar asked Sep 03 '13 14:09

DroidBeginner


1 Answers

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

How to implement a swipe-gesture between Fragments?

I suppose the Android ViewPager is what you are looking for:

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

Here is a nice tutorial on how to implement it:

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

The basic idea is that you have multiple Fragments, each representing a different Screen. The ViewPager enables the user to swipe between the different Fragments and display different content.

like image 94
Philipp Jahoda Avatar answered Oct 13 '22 11:10

Philipp Jahoda