Reputation: 23
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
Upvotes: 2
Views: 531
Reputation: 192
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);
Upvotes: 1
Reputation: 2912
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" />
Upvotes: 0