效果图参考:https://blog.csdn.net/qq_42483967/article/details/81479106
我代码的效果图:
步骤如下:
1.在app的buid.gradle中添加入AppBarLayout的依赖
implementation 'com.android.support:design:28.0.0'
2.activity_main.xml布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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"
tools:context=".MainActivity">