4

我试图在我的 XML 中使用 TextInputEditText,我遇到了这个错误:

Caused by: android.view.InflateException: Binary XML file line #15: 
Error inflating class android.support.design.widget.TextInputEditText

Caused by: java.lang.ClassNotFoundException: Didn't find class 
"android.support.design.widget.TextInputEditText" on path: 
DexPathList[[zip file "/data/app/thanhnguyen.com.familysharinglocation-
1/base.apk"],nativeLibraryDirectories=
[/data/app/thanhnguyen.com.familysharinglocation-1/lib/arm64, 
/system/lib64, /vendor/lib64]]

这是我的xml:

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

    <android.support.design.widget.TextInputEditText
        android:hint="@string/fullName"
        android:inputType="textCapWords"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>

我的依赖:

compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
4

2 回答 2

5

您需要使用 >= 24.1.0 的支持库版本,因为TextInputEditText它是在 version 中添加的24.1.0在TextInputEditText阅读更多内容

因此,您可以使用以下内容:

compile 'com.android.support:design:25.3.1'
于 2017-10-28T04:43:58.337 回答
1

确保您support design首先在 build.gradle 中添加了依赖项

将此 TextInputLayout 复制到您的 xml 中

 <android.support.design.widget.TextInputLayout
                android:id="@+id/userPhoneNumber"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_marginTop="20dp"
                android:clipToPadding="false"
                android:gravity="bottom"
                android:paddingTop="4dp"
                android:textColorHint="@color/whiteTextColor"
                >
                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_gravity="bottom"
                    android:background="@color/silveryBackground"
                    android:hint="@string/enterMobileNumber"
                    android:inputType="number"
                    android:maxLength="10"
                    android:paddingLeft="17dp"
                    android:paddingRight="17dp"
                    android:paddingTop="10dp"
                    android:singleLine="true"
                    android:textColor="@color/textColor"
                    android:textColorHint="@color/whiteTextColor"/>
            </android.support.design.widget.TextInputLayout>
于 2017-10-28T05:01:57.060 回答