Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to ellipsize the hint in the EditText?

The length of hint in my EditText is bit longer than the width of ET view. So how can i set marquee attribute to ET view. I have tried setting it, but the app crashes giving the error : E/AndroidRuntime(2095): Caused by: java.lang.IllegalArgumentException: EditText cannot use the ellipsize mode TextUtils.TruncateAt.MARQUEE

I have gone through the docs of ellipsize method, but not getting what i am supposed to do.I have tried these two steps :

1) android:maxLines="1" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever"

2) android:maxLines="1" android:scrollHorizontally="true"

Docs of ellipsize method: Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle. You may also want to setSingleLine() or setHorizontallyScrolling(boolean) to constrain the text to a single line. Use null to turn off ellipsizing. If setMaxLines(int) has been used to set two or more lines, only END and MARQUEE are supported (other ellipsizing types will not do anything).

Let me know what modification has to be done so that it works right.Thank you

like image 923
DJphy Avatar asked Nov 01 '22 07:11

DJphy


1 Answers

@DJphy - I found a solution no need to set ellipsis. when you are setting the string to edit text just set simple HTML attributes to string. Played with some HTML tricks and it worked for me. ex:- nameEdittxt.setHint(Html.fromHtml("<small><small><small>" + getString(R.string.enter_name) + "</small></small></small>"));

This will help to set hint smaller and Edit text size as normal you had set as fontsize. Look at my attachments - Before setting HTML attributes to hint - enter image description here

  • After setting HTML attributes to hint - enter image description here
like image 153
umesh Avatar answered Nov 12 '22 15:11

umesh