我希望我的应用程序能够在编辑文本中显示不同的提示在不同的时间,所以我必须在每个时间编程设置提示如下。
editText.setHint("Hint 1");但问题是,当我开始输入时,提示开始消失。我想显示这个提示,我在xml中设置的每个time.If,它不会在输入时消失,但在我的例子中如何做到这一点。
发布于 2016-10-05 15:03:00
或者你应该考虑改用TextInputLayout(强烈建议这样做。Here is an example too.)
或
根据您的需要,使用EditText作为输入,使用TextView作为提示inside.Change文本视图进行相对布局。
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Some text"
android:layout_alignParentLeft="true"
android:id="@+id/editText1"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/text_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="yourHint"
android:textSize="14sp"
android:layout_marginRight="10dp"
android:textColor="@color/customColor"
/>
</RelativeLayout>发布于 2016-10-05 15:04:19
你所期望的是不可能的,因为我们必须知道用户是如何在editext上写的。现在days https://github.com/hardik-trivedi/FloatingLabel这种类型的提示比较流行,你可以试试上面的链接。
发布于 2016-10-05 15:01:58
TextInputLayout为EditText提供了强大的材料特性。主要功能是浮动提示。请参阅此处的文档https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html
https://stackoverflow.com/questions/39867300
复制相似问题