Android Tab Layout not taking up full width with custom view

前端 未结 8 2430
谎友^
谎友^ 2021-02-15 17:03

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.

相关标签:
8条回答
  • 2021-02-15 17:59

    Try adding TabLayout in LinearLayout like:

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <android.support.design.widget.TabLayout
            android:id="@+id/sliding_tabs"
            style="@style/MyCustomTabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#FFF" />
    </LinearLayout>
    

    In Styles.xml add:

     <style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
        <item name="tabTextAppearance">@style/MyCustomTextAppearance</item>
    </style>
    
    <style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
        <item name="textAllCaps">false</item>
    </style>
    
    0 讨论(0)
  • 2021-02-15 18:02

    There are attributes in TabLayout : app:tabPaddingStart and app:tabPaddingEnd

    You can set -1 to both of them in order to remove padding start and end in custom view of TabLayout.

    <com.google.android.material.tabs.TabLayout
            android:id="@+id/tlEmojis"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:tabPaddingStart="-1dp"
            app:tabPaddingEnd="-1dp"
            app:tabMaxWidth="@dimen/dimen_48dp"
            app:tabMode="scrollable" />
    
    0 讨论(0)
提交回复
热议问题