代码之家  ›  专栏  ›  技术社区  ›  Abdurakhmon

不能在片段中使用textinputlayout

  •  0
  • Abdurakhmon  · 技术社区  · 7 年前

    我似乎无法在片段中使用textinputlayout。这是我的密码。

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical"
        android:gravity="center_horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".LoginFragment">
    
        <android.support.design.widget.TextInputLayout
            android:id="@+id/email_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <android.support.design.widget.TextInputEditText
                android:id="@+id/email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="email"
                android:inputType="textEmailAddress"
                android:maxLines="1" />
    
        </android.support.design.widget.TextInputLayout>
    
    </LinearLayout>
    

    当我试图运行时,我得到这个异常

    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputLayout"
    

    我把这个染红了 post 上面说我应该用 AppCompat Theme 我正在使用 AppCompat主题

    这是我的主题

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Abdurakhmon    7 年前

    将此依赖项添加到Gradle解决了问题

    implementation 'com.android.support:design:27.1.1'