首页 > 解决方案 > 更改 TextInputLayout 提示行为

问题描述

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

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

提前致谢!

标签: javaandroidkotlinmaterial-components-androidandroid-textinputlayout

解决方案


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

<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>

推荐阅读