Android TabLayout tabPaddingTop and tabPaddingBottom not being removed -


here 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 removing horizontal padding in between tabs not tabpaddingtop , tabpaddingbottom.

how remove top , bottom padding make each tab match tablayout height?

enter image description here

custom view 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 tried using linear layout imagview , textview 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 how inflated custom tab view (for custom view 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 can see, trying give different background color each tab. padding @ top , bottom still there.

i think android design library's tablayout have default padding can see here

the other recommendation can recommend using google io's slidingtablayout (don't forget copy slidingtabstrip too!)

the usage simple, include in layout :

<com.myapp.ui.widget.slidingtablayout     android:id="@+id/main_view_pager_tab"     android:layout_width="match_parent"     android:layout_height="@dimen/tabs_height"     android:background="@color/white" /> 

and in activity set viewpager , listener (if want)

    mainviewpagertab.setviewpager(mainviewpager);     mainviewpagertab.setonpagechangelistener(onpagechangelistener); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -