TabLayout的问题

问题描述 投票:0回答:1

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

下面是TabLaout的截图。

java android android-studio android-tablayout
1个回答
0
投票

如果我把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>

它的工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.