1.抽屉布局
可以设置头布局headerLayout和menu
<com.google.android.material.navigation.NavigationView android:layout_width="match_parent" android:layout_height="match_parent" app:headerLayout="@layout/head_item" android:id="@+id/nav" app:menu="@menu/menu" android:layout_gravity="left" android:background="#039BE5" ></com.google.android.material.navigation.NavigationView>
2.协调者布局
要放在相对布局里面
用CoordinatorLayout和AppBarLayout
记得app:layout_behavior里面写layout_scrollFlags外面的控件里面写layout_behavior才能实现
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" > <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="300dp" android:orientation="vertical"> <ImageView android:src="@mipmap/ic_launcher_round" android:layout_width="match_parent" android:layout_height="250dp" app:layout_scrollFlags="scroll" ></ImageView> <com.google.android.material.bottomnavigation.BottomNavigationView android:background="#FDD835" android:layout_width="match_parent" android:layout_height="50dp" android:id="@+id/bottom" ></com.google.android.material.bottomnavigation.BottomNavigationView> </com.google.android.material.appbar.AppBarLayout> <androidx.recyclerview.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/rv" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" ></androidx.recyclerview.widget.RecyclerView> </androidx.coordinatorlayout.widget.CoordinatorLayout> </RelativeLayout>
2.悬浮按钮
<com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/fad" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_marginRight="20dp" android:layout_marginBottom="20dp" android:clickable="true" app:rippleColor="#1E88E5" android:background="#FDD835" ></com.google.android.material.floatingactionbutton.FloatingActionButton>