【问题标题】:Issue with TabLayout选项卡布局问题
【发布时间】:2020-04-26 21:11:42
【问题描述】:

当我将 Tablayout 拖入布局时,它卡在左上角。 我正在使用安卓工作室 3.6.1。我已经添加了 实施 'com.google.android.material:material:1.1.0' 在构建 gradle 中。

Here is the screenshot of the TabLaout

【问题讨论】:

  • 你想达到什么目的?您只是希望它不会卡在左下角或其他什么地方?
  • 是的,其实我只是想让它正常工作。我添加了 tabItem 但看不到它也无法处理它。

标签: java android android-studio android-tablayout


【解决方案1】:

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

一切正常。

【讨论】:

  • 不适合我。软件或依赖项是否有问题?
猜你喜欢
  • 2015-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多