在TabLayout中设置最小高度将被忽略

时间:2019-05-06 13:02:53

标签: android android-layout android-linearlayout android-view android-tablayout

我有以下TabLayout

<android.support.design.widget.TabLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="100dp"
            app:tabSelectedTextColor="@color/white"
            app:tabBackground="@drawable/my_selector"
    />

我在选项卡中将以下布局设置为自定义视图。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal"
        android:background="@color/red"

>


    <TextView
            android:id="@+id/txt"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:paddingStart="16dp"
            android:gravity="center_vertical"
            android:text="FOO"
            android:textColor="@color/white"
    />


</LinearLayout>

并进行如下设置:

tabLayout.addTab(tabLayout.newTab().setCustomView(LayoutInflater.from(context).inflate(R.layout.my_layout, null)));  
    tabLayout.addTab(tabLayout.newTab().setCustomView(LayoutInflater.from(context).inflate(R.layout.my_layout, null)));  

问题: 我无法控制TabLayout的高度。我设置了minHeight时,它包装了内容。
我在这弄什么?

0 个答案:

没有答案