2

I am building an android app with tabs but the result I am getting is not what I wish for. I will like to implement something similar to what whatsapp has.

Below is what I want to do:

My Tab

my app's screenshot

Whatsapp

whatsapp screenshot

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Man Cuzzy
  • 23
  • 4

2 Answers2

1

This can be achieved like below

By xml

<android.support.design.widget.TabLayout
    android:id="@+id/tab"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Light"
    app:tabIndicatorColor="@android:color/white"
    app:tabIndicatorHeight="4dp"
    app:tabMaxWidth="0dp"
    app:tabMode="fixed" />

And programatically

tabLayout.setTabMode(TabLayout.MODE_FIXED);
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
Emmanuel Ayela
  • 192
  • 2
  • 11
0

Write this line inside Tablayout app:tabGravity="fill"

for example:

<android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMaxWidth="0dp"
            app:tabGravity="fill"
            app:tabMode="fixed" />
Däñish Shärmà
  • 2,891
  • 2
  • 25
  • 43