Here is my tab layout XML
<android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="@dimen/custom_tab_layout_height" android:background="@color/tab_background_primary" app:tabGravity="fill" app:tabIndicatorColor="@color/primary_white" app:tabIndicatorHeight="3dp" app:tabMinWidth="120dp" app:tabMode="scrollable" app:tabPaddingStart="-1dp" app:tabPaddingEnd="-1dp" app:tabPaddingTop="1dp" app:tabPaddingBottom="1dp" />
It is removing the horizontal padding in between tabs but not the tabPaddingTop and tabPaddingBottom.
How do I remove the top and bottom padding to make each tab match the tabLayout height?
Custom view for each tab
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab" android:textColor="@color/primary_white" android:textSize="14sp" android:textStyle="bold" android:gravity="fill" android:fontFamily="@string/font_fontFamily_medium"/>
I also tried using a Linear Layout with Imagview and Textview as custom view
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:gravity="fill" android:layout_height="match_parent"> <ImageView android:id="@+id/tab_logo" android:layout_width="wrap_content" android:layout_height="match_parent" android:src="@mipmap/ic_settings_light"/> <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/tab_title" android:textColor="@color/primary_white" android:textSize="14sp" android:textStyle="bold" android:gravity="center" android:text="test" android:fontFamily="@string/font_fontFamily_medium"/> </LinearLayout>
And here is how I inflated the custom tab view (for custom view with textView)
TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabTwo.setText("CASH IN"); tabTwo.setBackgroundColor(Color.parseColor("#EC5A0B")); tabTwo.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_action_cash_light, 0, 0, 0); tabLayout.getTabAt(1).setCustomView(tabTwo);
As you can see, I am trying to give different background color to each tab. But the padding at top and bottom is still there.