如何使文本输入布局提示多行?



我想使文本输入布局提示多行,材料大纲框甚至在浮动模式下提示。我已经搜索了很多,但没有找到任何解决方案,任何人都可以帮助我如何完成此任务?

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilFieldLabel"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:hintTextAppearance="@style/AddApplicationTextLabel">
<utilities.customcontrols.BodyEditText
android:id="@+id/etValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:gravity="start"
android:inputType="textMultiLine"
android:maxLength="1000"
android:textColor="@color/black"
android:textSize="@dimen/_13ssp"
android:theme="@style/AddApplicationEditTextField"
custom:customfont="bold" />

</com.google.android.material.textfield.TextInputLayout>

TLDR:

TextInputLayout设置app:hintEnabled="false"

描述:

如果将 hintEnabled 保留为 true(默认情况下为 true(,则提示将是单行,并在用户点击 EditText 时变为标签,使其获得焦点。

如果将提示启用更改为 false,则会删除此功能,并且 EditText 会按预期显示包含多行的提示。它不会变成标签,一旦用户开始实际键入,它就会消失。


<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:hintEnabled="false"
app:boxBackgroundMode="none">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Your long hint"/>
</com.google.android.material.textfield.TextInputLayout>

来源: https://stackoverflow.com/a/67744575/13545849

最新更新