簡體   English   中英

如何在接縫上放置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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM