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谁处理它不是协调员布局。