TextInputLayout 提示消失

我使用 TextInputLayout 来包装 TextInputEditText ,当我单击编辑文本开始输入提示时,提示消失而不是出现在行上方。

<android.support.design.widget.TextInputLayout
            android:id="@+id/animaldisc_et"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/breed_et">
            <android.support.design.widget.TextInputEditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Description"
                android:inputType="textPersonName"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.503"
                 />
        </android.support.design.widget.TextInputLayout>


慕田峪4524236
浏览 205回答 1
1回答

隔江千里

您的代码很好,提示没有消失,这可能是由于您的TextInputLayout和背景的颜色组合尝试使用一些鲜艳的颜色。对其进行了一些修改并将其放入线性布局中。<LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent">&nbsp; &nbsp; <android.support.design.widget.TextInputLayout&nbsp; &nbsp; &nbsp; &nbsp; android:layout_gravity="center"&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/animaldisc_et"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart="8dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginLeft="8dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop="16dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginEnd="8dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginRight="8dp"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf="parent">&nbsp; &nbsp; &nbsp; &nbsp; <android.support.design.widget.TextInputEditText&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:ems="10"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:hint="Description"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:inputType="textPersonName"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintEnd_toEndOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintHorizontal_bias="0.503"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; />&nbsp; &nbsp; </android.support.design.widget.TextInputLayout>&nbsp; &nbsp; </LinearLayout>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java