首页 > 解决方案 > 如何在android中实现垂直标签布局?

问题描述

我正在尝试在平板电脑上运行的应用程序上实现垂直选项卡布局。我试图将 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:id="@+id/staff_menu_tabs"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:orientation="vertical"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.tabs.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Tab 1"/>
        <com.google.android.material.tabs.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Tab 2"/>
        <com.google.android.material.tabs.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Tab 3"
           />

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


</androidx.constraintlayout.widget.ConstraintLayout>

在此处输入图像描述

标签: androidandroid-layoutkotlinmaterial-design

解决方案


推荐阅读