我注意到预览在许多电脑上都崩溃了,而不仅仅是我的电脑。但我目前遇到的最后一个问题是,在 TabLayout 中添加 TabItem 时,我找不到任何解决方案。我尝试了以下操作:
- 清除项目,重新构建项目
- 无效缓存并重新启动
- 重新启动我的笔记本电脑
- 检查该布局中是否有任何错误(没有错误,只有关于提取字符串的警告)
- 检查材料组件版本(我使用的是当前最新版本1.8.0)
也许是我忘记了一些愚蠢的东西,但现在我想不出来了。这是我的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.AdminActivity">
<com.google.android.material.tabs.TabLayout
android:id="@+id/adminTab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabIndicatorColor="@color/befc_blue"
app:tabSelectedTextColor="@color/befc_blue">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/chart"
android:text="Reports" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/croissant"
android:text="Hot Potatoes" />
</com.google.android.material.tabs.TabLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
这是我得到的错误信息:
![错误信息](https://istack.dev59.com/vFbpB.webp)
我尝试将默认的Material Design样式添加到选项卡布局中,但没有成功
textAppearanceTitleSmall
- 你在哪里使用它? - deadfish