无法在应用屏幕中显示FloatingActionButton

时间:2016-02-27 23:33:40

标签: android vector android-gradle android-appcompat floating-action-button

我将Android Studio中的Android支持库更新为版本23.2以开始使用底部表格,但在此之后,我无法在应用程序屏幕中显示FloatingActionButton。我收到以下错误:" android.content.res.Resources $ NotFoundException:无法找到资源ID#0x7f020054"

我在官方博客和Chris'中提到了一篇文章,讨论了在gradle中启用支持向量的标志。帖子:https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88

我正在使用Gradle插件的2.0.0-beta6版本。

如下所示,我已经在gradle文件中启用了支持向量。

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        defaultConfig {
            applicationId "br.com.jobcare.myapp"
            minSdkVersion 14
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            vectorDrawables.useSupportLibrary = true
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
        }

     }

     dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.2.0'
        compile 'com.android.support:design:23.2.0'
        compile 'com.android.support:support-v4:23.2.0'
        compile 'com.android.support:recyclerview-v7:23.2.0'
    }

以下是布局:

        <?xml version="1.0" encoding="utf-8"?>
        <android.support.v4.widget.DrawerLayout
            android:id="@+id/drawer_layout"
            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=".presenters.activities.MainActivity">

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

                <LinearLayout
                    android:id="@+id/container_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <include
                        android:id="@+id/toolbar"
                        layout="@layout/toolbar" />
                </LinearLayout>

                <FrameLayout
                    android:id="@+id/container_body"
                    android:layout_width="fill_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1" />

            </LinearLayout>

            <fragment
                android:id="@+id/fragment_navigation_drawer"
                android:name="br.com.jobcare.myapp.presenters.fragments.FragmentDrawer"
                android:layout_width="@dimen/nav_drawer_width"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                app:layout="@layout/fragment_navigation_drawer"
                tools:layout="@layout/fragment_navigation_drawer" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/add_event_floating_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|end"
                android:layout_margin="@dimen/fab_margin"
                app:srcCompat="@android:drawable/ic_input_add"
                android:onClick="showAddChoicePopupMenu"/>

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

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

不幸的是Android Studio中的错误,请参阅此处https://code.google.com/p/android/issues/detail?id=201861