第一种
效果图
image
1.添加依赖
//垂直的tablayout
implementation 'q.rorbin:VerticalTabLayout:1.2.5'
2.xml文件中添加控件【VerticalTabLayout集合帧布局使用,fragment开启事物的方法,或者直接用竖着的ViewPager】
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".ui.country.fragment.InternationalFragment">
android:id="@+id/tab"
android:layout_width="@dimen/dp_100"
android:layout_height="match_parent"
android:background="@color/c_EAEAEA"
app:indicator_width="@dimen/dp_2"
app:tab_height="@dimen/dp_50"
app:tab_mode="scrollable" />
android:id="@+id/fl_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
3.代码简单使用
mTab.setTab