Android 如何添加按钮以展开选项卡布局的选项卡
我有一个带有选项卡布局的xml文件。我想做的是添加一个按钮来展开它的选项卡。屏幕截图是我将选项卡布局放置到位的地方 请注意,片段中有两个选项卡布局。第一个是与viewpager2链接的,而我要展开的不是Android 如何添加按钮以展开选项卡布局的选项卡,android,xml,button,fragment,android-tablayout,Android,Xml,Button,Fragment,Android Tablayout,我有一个带有选项卡布局的xml文件。我想做的是添加一个按钮来展开它的选项卡。屏幕截图是我将选项卡布局放置到位的地方 请注意,片段中有两个选项卡布局。第一个是与viewpager2链接的,而我要展开的不是 您所说的“展开选项卡”是什么意思?意思是单击按钮时,选项卡布局显示为页面。 <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas
您所说的“展开选项卡”是什么意思?意思是单击按钮时,选项卡布局显示为页面。
<?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>