Check Mobile App
Read now
Start a Project

Android static TabLayout


Sometimes we have to give two or more (but limited) views in tabbed layout in android. For those it seems like a lot of work to create an new class FragmentPagerAdapter and attach it with the TabLayout. Here is a simple way you can take when you have less suppose 2 or 3 tabs and the tabs show entirely different data. In my case I have implemented a tabbed layout for Sign In and Sign Up.

So you simply have to create an activity in which you want the tabbed layout. But first lets create its XML. We will call it main.xml

And now our activity i.e

As you can see we have attached ViewPager.addOnPageChangeListener and TabLayout.addOnTabSelectedListener with each other. So that if you scroll ViewPager, tabs will change automatically and vice verses.

Now just create your fragments and you are ready to move ahead.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home