Remove Padding from Tabs when using TabLayout and ViewPager
app:tabPaddingEnd="0dp"
app:tabPaddingStart="0dp"
Notice, that this way doesn`t work for TOP and BOTTOM paddings, but I find next solution:
Reson to remoe padding from tabs:
1. Padding from Tabs when using Custom views with Tab Layout
1. Padding from Tabs when using Custom views with Tab Layout
<com.google.android.material.tabs.TabLayout
app:layout_constraintTop_toBottomOf="@id/viewpager"
android:id="@+id/tabs"
android:layout_width="match_parent"
app:tabSelectedTextColor="@color/colorPrimaryDark"
app:tabTextColor="@color/colorWhite"
android:layout_height="wrap_content"/>
Through XML you can remove only the left and right paddings like that:app:layout_constraintTop_toBottomOf="@id/viewpager"
android:id="@+id/tabs"
android:layout_width="match_parent"
app:tabSelectedTextColor="@color/colorPrimaryDark"
app:tabTextColor="@color/colorWhite"
android:layout_height="wrap_content"/>
app:tabPaddingEnd="0dp"
app:tabPaddingStart="0dp"
Notice, that this way doesn`t work for TOP and BOTTOM paddings, but I find next solution:
Before removing tab padding - the 3rd tab text size "WITHDRAWALS" is smaller compare to 1st two tabs. |
After removing extra tab padding - All tabs have text size. |
<com.google.android.material.tabs.TabLayout
app:layout_constraintTop_toBottomOf="@id/viewpager"
android:id="@+id/tabs"
android:layout_width="match_parent"
app:tabPaddingStart="0dp"
app:tabPaddingEnd="0dp"
app:tabSelectedTextColor="@color/colorPrimaryDark"
app:tabTextColor="@color/colorWhite"
android:layout_height="wrap_content"/>
app:layout_constraintTop_toBottomOf="@id/viewpager"
android:id="@+id/tabs"
android:layout_width="match_parent"
app:tabPaddingStart="0dp"
app:tabPaddingEnd="0dp"
app:tabSelectedTextColor="@color/colorPrimaryDark"
app:tabTextColor="@color/colorWhite"
android:layout_height="wrap_content"/>
how to remove space between image and text in tablayout
ReplyDelete