Tablayout 高度在平板电脑中不起作用

Tablayout height not working in tablet

我的 tablayout 的高度是环绕内容。但它不起作用。我在这里粘贴屏幕截图。它在手机上运行正常,但在平板电脑上运行不正常。

这个问题也与宽度有关,但标签 app:tabMaxWidth="0dp" 帮助我解决了问题。我怎样才能克服这个?这是布局代码。

<android.support.design.widget.TabLayout
    android:id="@+id/tablayout_add"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabMaxWidth="0dp"
    android:minHeight="0dp"
    android:layout_gravity="bottom"
    android:layout_below="@+id/relativeLayout"
    app:tabGravity="fill"
    app:tabBackground="@drawable/tab_color_selector"
    app:tabIndicatorColor="@color/sea_green"
    app:tabIndicatorHeight="2dp"
    app:tabMode="fixed"
    android:clickable="false"
/>

根据 material 设计指南,选项卡布局高度为 48dp。在尺寸文件中输入此值并在高度中使用该尺寸键。

选项卡布局选项卡文本大小为 14sp。

问题出在标签布局的父级上。 tablayout 没问题。这是父项的代码。

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/default_app_white"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >
        <android.support.design.widget.TabLayout
            android:id="@+id/tablayout_add"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMaxWidth="0dp"
            android:minHeight="0dp"
            android:layout_gravity="bottom"
            android:layout_below="@+id/relativeLayout"
            app:tabGravity="fill"
            app:tabBackground="@drawable/tab_color_selector"
            app:tabIndicatorColor="@color/sea_green"
            app:tabIndicatorHeight="2dp"
            app:tabMode="fixed"
            android:clickable="false"/>
</RelativeLayout>