Single tab in TabLayout is not covering the entire width

喜欢而已 提交于 2020-01-02 03:31:07

问题


I have created a view pager with TabLayout. Now the issue is if I have 2 or more tabs then everything is fine. But if I am having only one tab then it is not covering the entire screen width. PFA the xml layout

 <android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabMode="fixed"
        style="@style/TabLayout"
        android:fillViewport="true"
        android:layout_below="@id/ssrToolbar"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/sliding_tabs"
        android:layout_above="@+id/llButtonLayout"
        android:background="@android:color/white" />

Also here are the two images


回答1:


If someones still interested you should add this property for TabLayout in xml app:tabMaxWidth="big_number", for big_number i chose 2000dp. If you are not assigning any value default implementation subtracts widths measured specifications size with TAB_MIN_WIDTH_MARGIN value.



来源:https://stackoverflow.com/questions/33874385/single-tab-in-tablayout-is-not-covering-the-entire-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!