一、效果图
二、实现步骤
1.Build中添加引用
//viewpager2 implementation "androidx.viewpager2:viewpager2:1.0.0" //tab implementation 'com.google.android.material:material:1.2.1'
2.布局activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/color_white" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#0361CE" android:minHeight="160px"> <ImageView android:id="@+id/img_zhxz_back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="20px" android:src="@mipmap/img_back"/> <TextView android:layout_width="wrap_content" android:layout_height="wr