How to get Android textinputlayout tooltip in multiple lines?

I tried many of the available options on the Internet, but none of them seem to work.

I 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 also installed

 <item name="android:singleLine">false</item> 

in both TextLabel and EditText. But none of them work.

+9
android android-edittext
source share
2 answers

You can not.

TextInputLayout uses a CollapsingTextLayout , which measures the tooltip as CharSequence :

 mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) 

CharSequence has no concept of line, so you cannot add more.


This is not a hint if it takes so long. If you still want to display this, consider adding a separate TextView below / above / above and animate it (if you want / need).

+9
source share

Unlike simas answer, there seems to be a workaround. You can achieve the expected behavior by setting the tooltip programmatically in TextInputEdittext. The disadvantage is that the floating label does not work after that, I believe that this is not what we expect with such a long hint.

Important Note: If we set the tooltip for TextInputLayout, it will not work.

0
source share

All Articles