Xml 浮动操作按钮错误:在抽屉布局中使用时,对类android.support.design.widget.FloatingActionButton进行充气

Xml 浮动操作按钮错误:在抽屉布局中使用时,对类android.support.design.widget.FloatingActionButton进行充气,xml,android-fragments,inflate-exception,floating-action-button,Xml,Android Fragments,Inflate Exception,Floating Action Button,我目前使用抽屉布局作为根布局,以访问包含片段的滑动菜单。我想在所有片段中添加一个FAB,但得到错误- android.view.InflateException:二进制XML文件行#21:二进制XML 文件行#21:膨胀类时出错 android.support.design.widget.FloatingActionButton 我曾尝试将其包含在FrameLayout中,但仍然会出现相同的错误。我还尝试了多个图像,因为我知道当图像的像素数超过应用程序的内存时,可能会发生此错误。我的目标SDK是

我目前使用抽屉布局作为根布局,以访问包含片段的滑动菜单。我想在所有片段中添加一个FAB,但得到错误-

android.view.InflateException:二进制XML文件行#21:二进制XML 文件行#21:膨胀类时出错 android.support.design.widget.FloatingActionButton

我曾尝试将其包含在FrameLayout中,但仍然会出现相同的错误。我还尝试了多个图像,因为我知道当图像的像素数超过应用程序的内存时,可能会发生此错误。我的目标SDK是23,我已经编译了相关的appcompat库

一些额外的信息

主要活动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:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.liamk.version2.MainActivity"
    android:id="@+id/drawerLayout">


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

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/main_fragment">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|right"
                android:layout_marginBottom="@dimen/activity_vertical_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:src="@mipmap/ic_list_black_24dp"/>
        </FrameLayout>
    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/nav_menu"
        app:menu="@menu/navigation_menu"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigationheader">

    </android.support.design.widget.NavigationView>
    </android.support.v4.widget.DrawerLayout>
主题


@颜色/原色
@颜色/原色暗
@颜色/颜色重音
假的
真的

我找到了一个我忘记发布的解决方案

将选项卡布局用作父协调器布局中的子级。材料设计是你的朋友

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.liamk.version2"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'pub.devrel:easypermissions:0.2.1'
    compile('com.google.api-client:google-api-client-android:1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.apis:google-api-services-calendar:v3-rev225-1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
}
    <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>