TextInputLayout 导致设计问题

TextInputLayout causes design problems

提问人:Charon Ikh 提问时间:10/23/2023 最后编辑:Charon Ikh 更新时间:10/23/2023 访问量:22

问:

每次我将 EditText 替换com.google.android.material.textfield.TextInputLayout 时,字段中的所有信息(在我的情况下,密码输入字段)都会消失,从某种意义上说,无论如何都需要提示,但实际上没有,他只是消失了。我想使用这个特定的工具,因为我想添加在字段中查看输入密码的功能,因为我自己经常遇到必须多次检查其拼写正确性的问题。

使用不带 TextInput 的 TextInput,只需 EditText

XML 代码

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bglast"
    tools:context=".MainActivity"
    tools:ignore="ExtraText">

    <androidx.appcompat.widget.AppCompatButton
        android:id="@+id/buttonlogin"
        android:layout_width="364dp"
        android:layout_height="52dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:background="@drawable/edit_text_button"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:text="@string/Login"
        android:textColor="@color/WhiteText5"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword"
        app:layout_constraintVertical_bias="0.338"
        tools:ignore="ExtraText" />

    <TextView
        android:id="@+id/forgotpassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="24dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="8dp"
        android:text="@string/forgotfull"
        android:textColor="@color/GreyHint"
        app:layout_constraintBottom_toTopOf="@+id/buttonlogin"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.502"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword"
        app:layout_constraintVertical_bias="0.937" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="63dp"
        android:text="@string/Still"
        android:textColor="@color/GreyHint"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.424"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/buttonlogin"
        app:layout_constraintVertical_bias="0.208" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="63dp"
        android:text="@string/get"
        android:textColor="#2196F3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.645"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/buttonlogin"
        app:layout_constraintVertical_bias="0.208" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="24dp"
        android:fontFamily="@font/intersemibold"
        android:text="Welcome here,"
        android:textColor="@color/WhiteText5"
        android:textSize="34sp"
        app:layout_constraintBottom_toTopOf="@+id/textView5"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.63" />

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/editTextTextPassword"
        android:layout_width="347dp"
        android:layout_height="50dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="32dp"
        android:layout_marginEnd="16dp"
        android:autofillHints="password"
        android:background="@drawable/edit_text_background"
        android:ems="10"
        android:drawableStart="@drawable/passwordico"
        android:drawablePadding="16px"
        android:hint="Type your password"
        android:inputType="textPassword"
        android:paddingStart="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:textColor="@color/GreyHint"
        android:textColorHint="@color/GreyHint"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress"
        app:layout_constraintVertical_bias="0.111"
        tools:ignore="DuplicateSpeakableTextCheck" />

    <EditText
        android:id="@+id/editTextTextEmailAddress"
        android:layout_width="347dp"
        android:layout_height="50dp"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="32dp"
        android:autofillHints="emailAddress"
        android:background="@drawable/edit_text_background"
        android:ems="10"
        android:hint="Type your e-mail"
        android:inputType="textEmailAddress"
        android:paddingStart="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:shadowColor="@color/GreyHint"
        android:textColor="@color/GreyHint"
        android:textColorHighlight="@color/GreyHint"
        android:textColorHint="@color/GreyHint"
        android:textColorLink="@color/GreyHint"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.43"
        tools:ignore="ContentDescription,DuplicateSpeakableTextCheck" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="24dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="8dp"
        android:text="@string/Password"
        android:textColor="@color/WhiteText5"
        app:layout_constraintBottom_toTopOf="@+id/editTextTextPassword"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.044"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress"
        app:layout_constraintVertical_bias="1.0" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="8dp"
        android:text="@string/email"
        android:textColor="@color/WhiteText5"
        app:layout_constraintBottom_toTopOf="@+id/editTextTextEmailAddress"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.037"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="354dp"
        android:layout_height="37dp"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:fontFamily="@font/intersemibold"
        android:text="Good luck with your search!"
        android:textColor="@color/WhiteText5"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.225" />


</androidx.constraintlayout.widget.ConstraintLayout>


尝试添加实现“com.google.android.material:material:1.3.0-alpha01” 在 Gradle App 文件中,但它没有导致任何东西,它导致了错误,我不知道出于什么原因。我试图简单地将观察眼插入常规的 EditText 中 - 没有结果。因此,我想继续尝试使用它,但首先我需要修复它-_-

XML Android-Studio Gradle

评论


答: 暂无答案