Some code may help to implement an interface such as your drawing, as shown below.
The layout_anchor and layout_anchorGravity in the FloatingActionButton is the point.
<?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" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <android.support.v7.widget.CardView android:id="@+id/cv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level. This design means that your applications can use the libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up." /> </android.support.v7.widget.CardView> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.FloatingActionButton android:layout_height="wrap_content" android:layout_width="wrap_content" app:layout_anchor="@id/cv" app:layout_anchorGravity="right|end|bottom" android:layout_margin="16dp" android:clickable="true"/> </android.support.design.widget.CoordinatorLayout>
Edit:
There was some bug in the early answer in Android 5.0.1 and 5.0.2, FAB will show below CardView.
Add NestedScrollView with layout_behavior outside of CardView to work on Android 5.0.1 and 5.0.2
Ellie zou
source share