首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >安卓TextInputField充气错误

安卓TextInputField充气错误
EN

Stack Overflow用户
提问于 2015-06-02 00:52:25
回答 9查看 44.2K关注 0票数 28

在尝试使用新的安卓TextInputField时发生了崩溃,并想分享我的解决方案。

在android appcompat库中尝试新的TextInputField时,我的应用程序崩溃了。这是我的布局xml。

代码语言:javascript
复制
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="e-mail"
        android:inputType="textEmailAddress"
        android:singleLine="true"/>

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

我得到的错误是:

代码语言:javascript
复制
android.view.InflateException: Binary XML file line #20: Error inflating class android.support.design.widget.TextInputLayout.

解决方案:将hintTextAppearance属性添加到您的TextInputLayout中,使lead标记如下所示:

代码语言:javascript
复制
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@android:style/TextAppearance.Medium">
EN

回答 9

Stack Overflow用户

发布于 2015-10-01 23:27:17

这也发生在我身上,我想出了一个解决方案,不需要改变应用程序的主题,而只需要改变TextInputLayout的主题:

代码语言:javascript
复制
<android.support.design.widget.TextInputLayout
    android:id="@+id/testingInputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/Theme.AppCompat">

   <EditText
       android:id="@+id/testingEditText"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:hint="@string/testText"
       android:inputType="textEmailAddress" />

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

如果您尚未添加appCompat库,则需要添加该库:

代码语言:javascript
复制
compile 'com.android.support:appcompat-v7:23.0.1'
票数 24
EN

Stack Overflow用户

发布于 2019-07-30 11:31:41

在adroidx中,它对我有效,我有一些库

代码语言:javascript
复制
 implementation 'com.android.support:appcompat-v7:28.0.0'
    //design widget
    implementation 'com.android.support:design:28.0.0'

我改变了

代码语言:javascript
复制
<android.support.design.widget.TextInputLayout

代码语言:javascript
复制
<com.google.android.material.textfield.TextInputLayout
票数 19
EN

Stack Overflow用户

发布于 2016-07-26 19:05:27

使用以下内容:

代码语言:javascript
复制
View view = LayoutInflator.from(getActivity()).inflate(R.layout.your_layout_file,parent,false);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30578976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档