[英]How to position Android Floating Action Button on Seam
I have a Map and an area below representing a BottomSheet. 我有一张地图,下面有一个区域代表BottomSheet。
I would like to position a Floating Action Button on the seam between these two, on the right handside. 我想在这两个之间的接缝的右侧放置一个“浮动动作按钮”。
Can anyone offer any suggestions on how I might achieve this? 谁能提供有关我如何实现这一目标的建议?
XML follows, thanks for reading. 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>
Try using RelativeLayout instead of LinearLayout. 尝试使用RelativeLayout而不是LinearLayout。 And for FloatingActionButton add attribute like this,
对于FloatingActionButton这样的添加属性,
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end|bottom"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.