我正在尝试将 FAB 按钮附加到 BottomSheet 视图,就像 Google 地图一样。然而我无法让它发挥作用,
这是 FAB 按钮的代码:
<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/nestedscrollview" --> BottomSheet view ID
app:layout_anchorGravity="bottom|end"
app:elevation="4dp"
/>
这是 BottomSheet 视图的代码
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedscrollview"
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="wrap_content"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
tools:context="com.pub.uac.ui.location.LocationActivity"
android:background="@color/background_white_trasnparent"
>
...
</...
这取决于您所说的“无法使其发挥作用”的含义以及您试图实现的目标。
如果你在FAB上设置是不是效果会更好:
app:layout_anchorGravity="top|end"
你使用了“bottom”而不是“top”,所以FAB不会被底部的工作表推动,它会停留在底部。对于“顶部”,它至少应该跟随在工作表之后。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)