为什么“找不到 android.support.design.widget.TextInputL”

我的 Android Studio 版本是 3.4,我的 compileSdkVersion 29 和 buildToolsVersion“29.0.1”。我想使用 TextInputLayout,但出现此错误:缺少类:找不到以下类:- android.support.design.widget .TextInputLayout (Fix Build Path, Edit XML, Create Class) 提示:尝试构建项目。


我搜索了几天。我添加了这个


implementation 'com.android.support:appcompat-v7:29.0.1'

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

到我的 gradle 文件。但这个错误仍然存在。


这是我的 xml:


<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent">


    <com.example.studentv3.tools.RoundImageView

        android:id="@+id/admin_layout_pic"

        android:layout_width="100dp"

        android:layout_height="100dp"

        android:layout_centerHorizontal="true"

        android:layout_marginTop="100dp"

        android:src="@drawable/admin_photo" />


    <android.support.design.widget.TextInputLayout

        android:id="@+id/tt2"

        android:layout_below="@+id/admin_layout_pic"

        android:layout_width="match_parent"

        android:layout_height="wrap_content">


        <EditText

            android:id="@+id/admin_login_activity_name_input"

            android:layout_width="match_parent"

            android:layout_height="50dp"

            android:layout_below="@+id/admin_layout_pic"

            android:layout_centerHorizontal="true"

            android:layout_marginLeft="50dp"

            android:layout_marginRight="50dp"

            android:layout_marginTop="20dp"

            android:background="@drawable/input_box"

            android:gravity="center"

            android:hint="请输入账户"

            android:maxLines="1"

            android:paddingLeft="@dimen/input_box_left_padding"

            android:textColor="@color/grey_text" />

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


烙印99
浏览 113回答 2
2回答

温温酱

您可以使用材料设计来实现 TextInputEditText 和 TextInputLayout。使用最新版本的材料设计:api 'com.google.android.material:material:1.1.0-alpha06'然后实现如下。<com.google.android.material.textfield.TextInputLayout&nbsp; &nbsp; android:id="@+id/layout_username"&nbsp; &nbsp; style="@style/Widget.ChatMe.TextInputLayout"&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; android:layout_marginStart="32dp"&nbsp; &nbsp; android:layout_marginTop="100dp"&nbsp; &nbsp; android:layout_marginEnd="32dp"&nbsp; &nbsp; app:layout_constraintEnd_toEndOf="parent"&nbsp; &nbsp; app:layout_constraintStart_toStartOf="parent"&nbsp; &nbsp; app:layout_constraintTop_toTopOf="parent">&nbsp; &nbsp; <com.google.android.material.textfield.TextInputEditText&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/et_username"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:hint="Username" /></com.google.android.material.textfield.TextInputLayout>

慕容3067478

<com.google.android.material.textfield.TextInputLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/in1"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop="20dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_gravity="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:gravity="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textColorHint="#353536"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginLeft="15dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginRight="15dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app:passwordToggleEnabled="true">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EditText&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/loginPass"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_centerHorizontal="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:ems="10"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:inputType="textPassword"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:hint="@string/loginPassword"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingLeft="10dp" /></com.google.android.material.textfield.TextInputLayout>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java