如何添加按钮以扩展选项卡布局的选项卡

问题描述

我有一个带有选项卡布局的xml文件。我想要做的是添加一个按钮以扩展其选项卡。屏幕快照是我在其中使用标签页的位置。

请注意,片段中有两个选项卡布局。第一个是与viewpager2链接链接,而我要扩展的链接不是。

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto">
        
            <data>
        
            </data>
        
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:orientation="vertical">
        
                <com.google.android.material.tabs.TabLayout
                    android:id="@+id/tab_layout"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/dp_45"
                    app:tabGravity="center"
                    app:tabIndicatorColor="@color/color_theme"
                    app:tabIndicatorFullWidth="false"
                    app:tabIndicatorHeight="@dimen/dp_2"
                    app:tabInlineLabel="true"
                    app:tabMode="scrollable"
                    app:tabSelectedTextColor="@color/color_theme"
                    app:tabTextColor="@color/color_333"
                    app:tabUnboundedRipple="true">
                </com.google.android.material.tabs.TabLayout>
        
                    <com.google.android.material.tabs.TabLayout
                    android:id="@+id/sub_tabs"
                        app:tabBackground="@drawable/tab_background"
                        app:tabGravity="fill"
                        app:tabMode="scrollable"
                        android:layout_margin="5dp"
                        app:tabSelectedTextColor="#f57722"
                        android:clipToPadding="false"
                        app:tabPaddingStart="10dp"
                        app:tabPaddingEnd="10dp"
                        app:tabIndicatorHeight="0dp"
                        android:layout_width="match_parent"
                        android:layout_height="30dp" />
        
                <androidx.viewpager2.widget.ViewPager2
                    android:id="@+id/view_pager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">
                </androidx.viewpager2.widget.ViewPager2>
            </LinearLayout>
        </layout>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)