【发布时间】:2017-01-04 08:31:09
【问题描述】:
我的 android 抽屉布局有问题,其中包括浮动操作按钮以及 GLSurfaceView 的自定义实现。
问题是当我的布局中有 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>
但是当我删除 FAB 标签时,我得到了这个:
我在这里做错了什么??
【问题讨论】:
标签: android android-layout navigation-drawer floating-action-button