Android 如何在kotlin中将tabLayout上的选项卡项文本显示为两行或多行
我想将tabitem文本显示为两行或三行。这里我分享了我的代码。请检查一下。我已经尝试了文本的自定义样式。这是行不通的Android 如何在kotlin中将tabLayout上的选项卡项文本显示为两行或多行,android,kotlin,android-tablayout,Android,Kotlin,Android Tablayout,我想将tabitem文本显示为两行或三行。这里我分享了我的代码。请检查一下。我已经尝试了文本的自定义样式。这是行不通的 <com.google.android.material.tabs.TabLayout android:id="@+id/layout_tab" style="@style/Base.Widget.Design.TabLayout.Vehicle"
<com.google.android.material.tabs.TabLayout
android:id="@+id/layout_tab"
style="@style/Base.Widget.Design.TabLayout.Vehicle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabTextAppearance="@style/TextAppearance.Design.Tab.2Line">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_compact_car"
android:text="@string/car" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_coupe_car"
android:text="@string/bike" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_sedan_car"
android:text="@string/bus" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_suv_car"
android:text="@string/jeep" />
</com.google.android.material.tabs.TabLayout>