gpt4 book ai didi

Android 无法将 FAB 按钮锚定到 BottomSheet

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:06:25 25 4
gpt4 key购买 nike

我正在尝试将 FAB 按钮附加到 BottomSheet View ,就像 Google map 所做的那样。但是我无法让它工作,

这是 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 View 的代码

<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 不会被 bottom sheet 插入,它会留在底部。对于“top”,它至少应该跟在工作表之后。

关于Android 无法将 FAB 按钮锚定到 BottomSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36958023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com