Android错误膨胀类TextInputLayout

时间:2015-08-17 08:45:20

标签: android android-design-library

我正在尝试在我的XML中使用TextInputLayout,我遇到了这个错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.jechange.moncompte/fr.jechange.moncompte.SignUpActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;

我已导入设计库和support-v7-appcompat库。我正在使用Theme.AppCompat.Light.NoActionBar主题。

我正在使用文本输入布局的XML包含类似的内容:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:res="http://schemas.android.com/apk/res-auto"
style="@style/matchParent">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:inputType="text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.TextInputLayout>
</RelativeLayout>

2 个答案:

答案 0 :(得分:1)

如果您从活动中调用布局(包含TextInputLayout) 没有什么只是使用YouActivityClassName.this代替getApplicationcontext或YourApplicationClassName.getcontext()或其他传递上下文的地方

答案 1 :(得分:0)

我修复了同样的问题here。 确保您没有任何其他支持库导入v4和v7。您只能使用设计支持库。此外,你应该确保你的主题&#34; matchParent&#34;从您尝试运行的所有平台继承Theme.AppCompat。 由于values-21/style.xml,我的问题只出现在Lollipop上。

希望它会有所帮助。