如何在 Seam 上定位 Android 浮动操作按钮
How to position Android Floating Action Button on Seam
我有一个地图和下面代表 BottomSheet 的区域。
我想在右手边这两个按钮之间的接缝处放置一个浮动操作按钮。
任何人都可以就我如何实现这一目标提供任何建议吗?
XML如下,感谢阅读
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Map -->
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:longClickable="true"
app:cameraZoom="15"
app:mapType="normal"
android:layout_above="@+id/botsheet_frame"/>
<!-- FAB -->
<android.support.design.widget.FloatingActionButton
android:id="@+id/myFAB"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/botsheet_frame"
app:layout_anchorGravity="bottom|right|end"
android:src="@android:drawable/ic_dialog_email"
android:layout_margin="16dp"
android:clickable="true"/>
<!-- place holder for basic BottomSheet area-->
<RelativeLayout
android:id="@id/botsheet_frame"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
android:padding="6dp">
<!-- TextView to be added here -->
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
尝试使用 RelativeLayout 而不是 LinearLayout。并为 FloatingActionButton 添加这样的属性,
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end|bottom"
我有一个地图和下面代表 BottomSheet 的区域。
我想在右手边这两个按钮之间的接缝处放置一个浮动操作按钮。
任何人都可以就我如何实现这一目标提供任何建议吗?
XML如下,感谢阅读
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Map -->
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:longClickable="true"
app:cameraZoom="15"
app:mapType="normal"
android:layout_above="@+id/botsheet_frame"/>
<!-- FAB -->
<android.support.design.widget.FloatingActionButton
android:id="@+id/myFAB"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/botsheet_frame"
app:layout_anchorGravity="bottom|right|end"
android:src="@android:drawable/ic_dialog_email"
android:layout_margin="16dp"
android:clickable="true"/>
<!-- place holder for basic BottomSheet area-->
<RelativeLayout
android:id="@id/botsheet_frame"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
android:padding="6dp">
<!-- TextView to be added here -->
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
尝试使用 RelativeLayout 而不是 LinearLayout。并为 FloatingActionButton 添加这样的属性,
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end|bottom"