我试图在我的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'
答案 0 :(得分:4)
您需要使用支持库版本&gt; = 24.1.0,因为版本TextInputEditText
中添加了24.1.0
。阅读更多TextInputEditText
因此,您可以使用以下内容:
compile 'com.android.support:design:25.3.1'
答案 1 :(得分:1)
确保您已在build.gradle中添加support design
依赖项
在xml中复制此TextInputLayout
<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>
答案 2 :(得分:0)
试试这个
您必须使用android.support.design.widget.TextInputEditText
EditText
<android.support.design.widget.TextInputLayout
android:id="@+id/fullName"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:hint="@string/fullName"
android:inputType="textCapWords"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>