使用任何Android的设计支持程序库元素时出错 [英] Error when using any Android Design Support Library Elements

查看:162
本文介绍了使用任何Android的设计支持程序库元素时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误从设计支持库充气什么

Error inflating anything from the design support library

XML

<android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

build.gradle

dependencies {
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v13:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'

项目build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

错误:

Binary XML file line #115: Error inflating class
android.support.design.widget.FloatingActionButton

我的SDK管理器一切都是最新的。

My Sdk Manager everything is up to date.

推荐答案

另外,你可能面临以下问题。伊曼纽尔的答案

In addition to Emmanuel's answer you could be facing the following problem.

这似乎是设计库组件需要一个风格,是基于一个AppCompat主题。因此,尝试使用Theme.AppCompat。[...]作为您的style.xml父母。

It seems like the design library components need a style which is based on an AppCompat Theme. So try to use "Theme.AppCompat.[...]" as a parent in your style.xml.

例如:

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.AppTheme">
    <!-- Customize your theme here. -->
</style>

<style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:colorPrimary">@color/primary</item>
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <item name="android:colorAccent">@color/accent</item>
</style>

然后添加以下到您的build.gradle还有:

Then add the following to your build.gradle as well:

compile 'com.android.support:appcompat-v7:22.2.0'

此外,你应该更新您的摇篮以下行,以及:

Additionally you should update the following lines in your gradle as well:

classpath 'com.android.tools.build:gradle:1.2.3'
compileSdkVersion 22
buildToolsVersion '22.0.1'
targetSdkVersion 22

这篇关于使用任何Android的设计支持程序库元素时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆