效果
能滑动后得到
一,一个基本的主页面导入viewpager
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
二,给出想要滑动的三个页面用不同的颜色区分
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF03DAC5"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/pg1"
android:layout_width="wrap_content"
android:layout_height="