【发布时间】:2018-01-31 13:27:27
【问题描述】:
我正在努力使用一个浮动按钮,该按钮根据底部工作表片段的位置上下移动。 我想要像谷歌地图一样的东西,无论底部工作表是否移动,浮动按钮也会一起移动。
此时我的活动是这样的
我有一个在片段中加载地图的活动,像这样
<android.support.design.widget.CoordinatorLayout 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="match_parent"
tools:context="br.com.vix.v1motorista.MotoristaActivity">
<!-- here the map is loaded -->
<FrameLayout
android:id="@+id/conteudo"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:layout_marginBottom="16dp"
android:visibility="visible"
app:layout_anchor="@+id/conteudo"
app:layout_anchorGravity="right|bottom"
app:srcCompat="@drawable/ic_info_white_36dp" />
<!-- Adding bottom sheet after main content -->
<include android:id="@+id/pickUpFragment" layout="@layout/fragment_pax_pick_up_2" />
我已经尝试将 FloatingButton 移动到底部工作表片段 xml 文件,它几乎可以工作,但是如果我关闭片段,浮动按钮将与底部工作表片段一起消失,并且浮动按钮也没有完全显示底部工作表被“隐藏”了。
【问题讨论】:
标签: android android-fragments maps floating-action-button bottom-sheet