2017-05-03 46 views
0

我遇到問題,浮動動作按鈕在協調器佈局中的底部工作表上不重疊。我怎麼解決這個問題?底層佈局是一個地圖片段。浮動動作按鈕不重疊底部工作表

The layout looks like this

的XML看起來如下:

<?xml version="1.0" encoding="utf-8"?> 
<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"> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/floatingActionButtonAdd" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="-32dp" 
     android:layout_gravity="end|top" 
     android:src="@drawable/ic_add_white_48dp" 
     app:backgroundTint="@color/colorPrimary" 
     app:borderWidth="0dp" 
     app:elevation="4dp" 
     app:fabSize="normal"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:id="@+id/linear_layout_bottom_sheet"> 

     <!-- include bottom sheet --> 
     <include layout="@layout/bottom_sheet_peek" /> 

     <!-- include main content --> 
    <include layout="@layout/bottom_sheet_content" /> 

    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 
+0

也許,你的底紙的高程屬性高於FAB。 –

+0

你嘗試過使用framelayout而不是linearlayout嗎? – Umair

+0

我不認爲它會使用這種佈局。 FAB不應該是底部表格的一部分。 – natario

回答

0

嘗試的LinearLayout設置正marginTop並從FAB負一:

<?xml version="1.0" encoding="utf-8"?> 


<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"> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/floatingActionButtonAdd" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|top" 
     android:src="@drawable/ic_add_white_48dp" 
     app:backgroundTint="@color/colorPrimary" 
     app:borderWidth="0dp" 
     app:elevation="4dp" 
     app:fabSize="normal"/> 

    <LinearLayout 

     android:layout_marginTop="32dp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:id="@+id/linear_layout_bottom_sheet"> 

     <!-- include bottom sheet --> 
     <include layout="@layout/bottom_sheet_peek" /> 

     <!-- include main content --> 
     <include layout="@layout/bottom_sheet_content" /> 

    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 
+0

這也不起作用,[在此是圖像](https://photos.google.com/share/AF1QipPM0w6Gxo6dXiNHZWIm88BNNJQ_flCHytTKJdHfuH_DEIi8a0ps6zrfgEmaDF4PnA?key=UWpkUERHWjUteDNucWwydjVCLXVGOElHand5UmxB) – Thavit

+0

嘗試設置透明背景CoordinatorLayout和白色背景的LinearLayout –