How to make custom tabs with text & icons in android

Save

In this blog,
We are going to show you how to make custom tabs in android.

Here we customize the tab with icon and text, you can see the icon is horizontally aligned with tab text.

But if you want to place the icon above the tab label, you have to use a custom view to achieving it.

 

Code Implementation

1. Open project level build.gradle and add android design support library com.android.support:design:23.0.1

2. In layout file activity_main.xml and add tablayout and view pager.

 

3. Create an XML layout named custom_tab.xml under res -> layout for define the custom view for the tab.

4. Create a fragment named Fragment1.java for tab contents

 

5. In MainActivity.java use the below code for customizing the tab.

If you noticed this function createTabIcons in MainActivity.java, I have used custom_tab.xml layout in each tab.

MainActivity.java


      Custom view for tab layout

Screenshot_3

Maybe this blog is work for you.

 

Source:

www.androidhive.info/

. . .

Leave a comment

6 Comments

css.php

All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.

Josh Arnold

Josh Arnold

Owner, Shop ATV Escape

Talk to Sales

Global

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