Search code examples
androidandroid-fragmentsandroid-viewpagerandroid-tablayoutui-design

Android TabLayout without tabs; Creating MyFitnessPal style tablayout


I want to create a diary where you can input your expenses for the day as well as past/future days, so I wish to create a viewpager style tablayout to swipe between days. The problem is, I don't know how to use a ViewPager and hide the actual layout where the different tabs are visible, but instead implement some sort of 'Swipe to move' to the previous/next day feature without all the tab names showing up on screen.

A well documented example of what I'm trying to explain is implemented in the Diary section of the MyFitnessPal Android app

I have some sort of idea on how to do it, I was considering an option where in I manually create a fragment and listen for swipes and replace the fragment accordingly, but I feel like I'm missing something that might already be a feature in tablayouts to customize tab headings and style to achieve what I want to.

What would be the best way to go about this? Code and/or a walk-through would be much appreciated!


Solution

  • create a new project using android studio, there on "Add an Activity to Mobile" screen scroll down and select the last option "Tabbed Activity". On next screen in "Navigation Style" dropdown option select "Swipe Views (Viewpager)" and click finish.