Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Tab Layout not taking up full width with custom view

Android TabLayout tabPaddingTop and tabPaddingBottom not being removed

Please refer to the above issue as well.

Even since i updated my design library to "23.2.0", Tab layout is all messed up.

The below image is my Tab Layout.

Xml Part :-

<android.support.design.widget.TabLayout
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabIndicatorColor="@android:color/white"
    app:tabIndicatorHeight="@dimen/dp2"
    app:tabMode="fixed"
    app:tabSelectedTextColor="@android:color/white"
    app:tabTextAppearance="@style/MyCustomTabTextAppearance" />

styles xml :-

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/color_156084</item>
</style>

<style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">@dimen/sp14</item>
    <item name="android:textColor">@android:color/white</item>
    <item name="textAllCaps">false</item>
</style>

I have set padding to -1dp and even did tabGravity to fill but nothing is working.

This code used to work in earlier versions but now if i am downgrading it, i am getting a no class def found error on TintManager.

enter image description here

like image 862
Rahul Gupta Avatar asked Mar 08 '16 06:03

Rahul Gupta


People also ask

How is tabbing implemented in an android layout?

Tabs are created using newTab() method of TabLayout class. The title and icon of Tabs are set through setText(int) and setIcon(int) methods of TabListener interface respectively. Tabs of layout are attached over TabLayout using the method addTab(Tab) method.


1 Answers

Try adding below attributes to TabLayout:

app:tabPaddingStart="-1dp"
app:tabPaddingEnd="-1dp"

Hope it'll work.

like image 103
Vishnu Ps Avatar answered Oct 23 '22 09:10

Vishnu Ps