在输入字段的下面添加提示文本
目前,我拥有一个具有一个数据输入字段的最简单的一页应用程序。我查看了很多示例,但是找不到问题的答案:如何在输入字段的底部添加提示文本?
<?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"
tools:context=".MainActivity">
<EditText
android:id="@+id/editTextUserId"
android:layout_width="347dp"
android:layout_height="60dp"
android:layout_marginBottom="20dp"
android:ems="10"
android:hint="User"
android:inputType="textPersonName"
android:text="@string/user_id"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/imageButton"
app:layout_constraintEnd_toEndOf="@+id/editTextDeviveId"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/editTextSessionId"
app:layout_constraintTop_toBottomOf="@+id/editTextDeviveId"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
At the moment, I have the simplest one-page application with one data entry field. I looked at a lot of examples, but I could not find the answer to my question: how do I add hint text at the bottom of the input field?
<?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"
tools:context=".MainActivity">
<EditText
android:id="@+id/editTextUserId"
android:layout_width="347dp"
android:layout_height="60dp"
android:layout_marginBottom="20dp"
android:ems="10"
android:hint="User"
android:inputType="textPersonName"
android:text="@string/user_id"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/imageButton"
app:layout_constraintEnd_toEndOf="@+id/editTextDeviveId"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/editTextSessionId"
app:layout_constraintTop_toBottomOf="@+id/editTextDeviveId"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加文本视图并将其限制在您的Edittext
下方
像这样的活动
Add a Textview and Constrain it below your Edittext
Then if you want to show/hide it base on user interaction you can do something
like this in your activity