I have a custom edittext and I'm having some problems with the ellipisze.
My edittext is build programmatically and has the following attributes:
setSingleline(true);
setInputType(InputType.TYPE_NULL);
setCursorVisible(false);
setEllipsize(TruncateAt.END);
setText(com.telecomIT.digicare.R.string.comment_hint);
But the ellipsize isn't working. The weird thing is that if I change setText to setHint, the 3 dots are displayed.
So, why does it work with hint, but not with text?
I already tried to set the inputtype to text, but this doesn't work either.
Try changing the input type to something other than Null.
Related
when I replace maxlines with singleLine or replace text(databinding) with static text, ellipsize = "end" is fine. And this is not constraintLayout's problem.
how can I fix this problem except truncating text and replacing by adding '...'?
In my case, ellipsis got broken by setMovementMethod(LinkMovementMethod.getInstance()), used to get links working.
I have a textInputLayout with a TextInputEditText.
I would like the hint text to be in Roboto and the edit field (the text that user is entering) to be of a custom font, but can't seem to get it working. Somehow if I try to set a font on the TextInputEditText it also affects the hint text's font.
Anyone know how to get this issue solved?
*** edit: Found some weird thing. When I set the inputType to textPassword on the TextInputeditText (and have my custom font set on same widget via fontFamily=".." then I do have two different fonts on hint and edit field?!! But unfortunately for any other input type and in my case I need inputType="textEmailAddress" the hint text changes to same font as TextInputEditText
I found the solution:
You need to set typeFace on the TextInputLayout programmatically for the font you want for the hint text.
The font for the TextInputEditText fields can be set directly in either xml or programatically.
Default EditText does not offer a method to set the Typeface of the hint only, but if you set a custom typeface to your EditText, all the text fields are affected.
To obtain what you want, you need to define a custom TypefaceSpan and a SpannableString, as suggested in this topic.
Please have a look at francisco_ssb answer.
Getting quite frustrated with this issue.
I have got two underlines for all my EditText and I don't know why this is happening.
How do I remove the black underline color?
The turquoise underline is part of the default EditText widget background. You can remove it by setting the background XML attribute to #null.
The black underline is likely caused by predictive text. This can be corrected by adjusting your inputType, also in XML.
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
I think marquee doesn't works for EditText.You can use other attribute to ellipsize hint if it is getting longer than the size of editText.
android:ellipsize="end"
#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 -
After setting HTML attributes to hint -
I want to remove the underlines from texts inside edittext fields.
How can I do that?
You can do it with following code. Just paste it in layout of EditText.
android:inputType="textNoSuggestions"
In order to get rid of spell checking you have to specify the EditText's InputType in the XML as the following:
android:inputType="textNoSuggestions"
However, if your EditText is multiline and also you need to get rid of spell checking,then you have to specify the EditText's InputType in the XML as the following:
android:inputType="textMultiLine|textNoSuggestions"
Minor addition to Chintan's answer - such (and other) combination is also allowed:
android:inputType="textCapSentences|textNoSuggestions"
Or if you want to just disable the red underline (and the autocorrect dialog), you can override the isSuggestionsEnabled() method on TextView.
This will keep the keyboard autocomplete working.
I just Added a line in for EditText
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
and it worked fine for me.
So I was not able to find out any direct way of doing it. So went ahead with below workaround:
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
As the input type becomes a visible password, even if the spell check is enabled from the device settings, the Red underline won't appear. :)