前言
Tablayout介绍:Tablayout是继承自HorizontalScrollView,用作页面切换指示器,实现顶部导航。
ViewPager介绍:ViewPager可以实现左右翻转带数据的页面,你想要显示的视图可以通过实现PagerAdapter来显示。
自制的实现效果
1、最初切换效果
实现效果图:
动态效果展示:
布局代码:
<com.google.android.material.tabs.TabLayout
android:id="@+id/record_tabs"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
app:tabGravity="center"
app:tabMode="fixed"
app:tabTextColor="@color/grey_7D7D7D"
app:tabSelectedTextColor="@color/black"
app:tabIndicatorColor="@color/black"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/record_vp"
android:layout_width="match_parent"
android: