0

I want to make Textinputlayout hint multiline with material outlinedbox even hint in floating mode. I have searched a lot but didn't found any solution can anyone help me how to achieve this task?

<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>
Ahsan
  • 19
  • 2
  • 8

1 Answers1

0

TLDR:

Set app:hintEnabled="false" for TextInputLayout

Description:

If you leave hintEnabled to true (true by default) the hint will be single line and turns into a label when the user taps the EditText giving it focus.

If you change hintEnabled to false this feature is removed and the EditText shows the hint with multiple lines as intended. It does not turn into a label and disappears once the user starts actually typing.


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

Source: https://stackoverflow.com/a/67744575/13545849

FreePhoenix888
  • 4,510
  • 3
  • 13
  • 22