I have tried many options available online but none of them seem to be working.
I have used this XML for this purpose.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextLabel">
<com.projects.fonts.RobotoEditText
style="@style/EditText"
android:hint="@string/description"
android:singleLine="false"
app:font="@string/roboto_regular" />
</android.support.design.widget.TextInputLayout>
I have also set
<item name="android:singleLine">false</item>
in both TextLabel and EditText. But none of them are working.
You can do this with TextInputLayout and TextInputEditText.
In the TextInputEditText set the hint as you normally would (android:hint="Hint Text").
In the TextInputLayout you must disable the hint by setting "app:hintEnabled="false".
Notes:
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.
Example code below:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With