2

我需要以这种方式更改 TextInputLayout 行为。默认情况下,当用户单击布局内的 EditText 时,提示会离开文本框并位于上方。我需要实现的是:当用户点击 EditText 时,提示没有反应。当用户开始输入时它会移动,然后返回时 EditText 为空。

我使用了一个名为 FloatingEditText 的自定义库,但它不能与 RTL 布局一起正常工作。有谁知道如何使用 TextInputLayout 或其他从右到左工作的方式来实现这一点?

提前致谢!

4

2 回答 2

0

您可以在标签部分输入要输入的名称,在印度部分输入提示。

<android.support.design.widget.TextInputLayout
        android:id="@+id/text_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Label">

        <EditText
            android:id="@+id/edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text" />

    </android.support.design.widget.TextInputLayout>
于 2018-06-11T07:39:26.117 回答
0

使用材料组件库,您可以使用以下placeholderText属性:

    <com.google.android.material.textfield.TextInputLayout
        android:hint="Label"
        app:placeholderText="placeholder"

在此处输入图像描述

注意:这至少需要版本1.2.0.

于 2020-08-16T07:39:27.373 回答