java - TabLayout 的问题

标签 java android android-studio android-tablayout

当我将 Tablayout 拖到布局中时,它卡在左上角。 我使用的是android studio 3.6.1。我已经添加了 实现 'com.google.android.material:material:1.1.0' 在构建 gradle 中。

Here is the screenshot of the TabLaout

最佳答案

如果我将 TabLayout 更改为

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <com.google.android.material.tabs.TabLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent">
        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="Monday"/>
        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="Tuesday"/>
        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="Wednesday"/>

    </com.google.android.material.tabs.TabLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

工作正常。

关于java - TabLayout 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61422161/

相关文章:

android - 有没有办法设置android :windowSoftInputMode by Fragment?

Android WebView 问题

android - 设置按钮文本以匹配所有 Android 中的最小文本大小

java - 为什么我应该用 null 对象替换 null 文字?

android - Android 对话框回答太快时代码未执行(竞争条件)

java - 向 JSF 2 数据表动态添加行组件

android - 发现GPU。供应商 ID 10de 设备(如果 0x1f07 检查错误的 AMD Vulkan 驱动程序版本)

android - 如何在 Android Studio 中设置外部文档?

java - 向表中插入数据时生成 SQl 语法异常

javafx折线图排序数据