我想在我的底页上设置一个锚点:
<!-- bottom sheets -->
<LinearLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:padding="10dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="bottom sheets test! " />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! bottom sheets content! " />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"
app:layout_anchor="@id/bottom_sheet"
app:layout_anchorGravity="bottom|end" />
我将 FAB 添加为 CoordinateLayout 的直接子级,并将底部工作表的 id 设置为 FAB 的 layout_anchor 并设置其 layout_anchorGravity。但它不起作用。FAB 不会移动。