1

我正在嘗試在CoordinatorLayout中添加FAB,MapView,工具欄和DrawerLayout。我的地圖視圖將覆蓋整個屏幕,FAB將放置在地圖視圖上。我已經實現了一切,但問題出在地圖視圖上。我無法與之互動。另外,當我打開抽屜時,它正在低於FAB的位置,用戶可以與我不想要的交互。無法與CoordinatorLayout中的地圖視圖交互

以下是我的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:fitsSystemWindows="true" 
tools:context=".MainActivity"> 

<com.google.android.gms.maps.MapView 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:visibility="visible" 
    app:layout_anchor="@+id/navigation_drawer" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.v4.widget.DrawerLayout 
    android:id="@id/navigation_drawer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/colorAccent" 
      app:popupTheme="@style/AppTheme.PopupOverlay" 
      tools:showIn="@layout/activity_map_view"> 

      <TextView 
       android:id="@+id/toolbar_title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="@string/app_name" 
       android:textSize="18sp" /> 
     </android.support.v7.widget.Toolbar> 
    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:menu="@menu/navigation_items" /> 

</android.support.v4.widget.DrawerLayout> 

<RelativeLayout 
    android:id="@+id/fab_container" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_marginBottom="40dp"> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab3" 
     style="@style/floating_action_button" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:src="@android:drawable/ic_dialog_email" 
     app:fabSize="mini" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab2" 
     style="@style/floating_action_button" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:layout_below="@id/fab3" 
     android:src="@android:drawable/ic_menu_week" 
     app:fabSize="mini" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab1" 
     style="@style/floating_action_button" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:layout_below="@id/fab2" 
     android:src="@drawable/cast_ic_notification_1" 
     app:fabSize="mini" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     style="@style/floating_action_button" 
     android:layout_width="56dp" 
     android:layout_height="56dp" 
     android:layout_below="@id/fab1" 
     android:src="@drawable/ic_plusone_medium_off_client" 
     app:backgroundTint="#00FF00" 
     app:fabSize="normal" /> 
</RelativeLayout> 

而且當我設置DrawerLayout的知名度「走了」,我可以用地圖這表明我的DrawerLayout是地圖視圖上面,我無法擺脫它互動。

我的XML的任何問題?附件是抽屜打開和關閉時的截圖。 I want FAB below the drawer menu so that user can not interact with it. I can not interact with the map

在此先感謝。

+0

你可以發佈它應該看起來的截圖(可能是來自前棒棒糖設備的截圖)。另外,我懷疑你會想要在appbar中使用mapView,因爲appbar通常用於諸如Toolbars和TabLayouts之類的東西。 –

+0

@ G.deWit感謝您的評論。從AppBarLayout中刪除了地圖視圖,它對所有設備都正常工作。 – Amrut

+0

@ G.deWit但是現在我的導航欄在預棒棒糖設備上不可見。 – Amrut

回答

0

您是否嘗試刪除app:layout_behavior =「@ string/appbar_scrolling_view_behavior」,因爲這是用於內容滾動的,但是您的視圖正在填充視圖,因此它不可滾動只有可滾動的地圖,但它是mapView誰處理它不是協調員佈局。