因为setUserVisibleHint方法过时,本文采用Viewpage2进行搭建
一个超级简单的demo,记录一下使用笔记,项目框架采用MVVM模式,以及DataBinding,所有控件都是通过DataBinding获取
首先看一下布局文件
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="@+id/home_tv"
android:layout_width="match_