0

У меня возникла проблема с макетом ящика Android, который включает в себя плавучую кнопку действия, а также пользовательскую реализацию GLSurfaceView.Android DrawerLayout + FAB issue

Проблема в том, что когда у меня есть FAB в моем макете, все работает так, как ожидалось. Однако, когда я удаляю FAB из моего макета, я получаю некоторые странные результаты.

Вот мой layout.xml файл:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="com.me.myapp.NavDrawerActivity"> 

    <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="com.me.myapp.NavDrawerActivity"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay" 
      > 

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

     </android.support.design.widget.AppBarLayout> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <com.me.myapp.MySurfaceView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/surface" 
       /> 

     </RelativeLayout> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      android:src="@android:drawable/ic_dialog_email" /> 



    </android.support.design.widget.CoordinatorLayout> 

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

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

Это выглядит так, как ожидалось: looks ok

Но когда я удалить тег ФАБ, я получаю это:

enter image description here

Что я здесь делаю неправильно?

ответ

0

изменение RelativeLayout к этому:

<RelativeLayout 
      android:layout_width="match_parent" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      android:layout_height="match_parent"> 

      <com.me.myapp.MySurfaceView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/surface" 
       /> 

</RelativeLayout> 
Смежные вопросы