I have a TextView with a maxWidth that I want to loop its text in an animation, if the text is too long to fit in this width.
I want this animation to be smooth, infinite, and to have a certain margin between the end of the text to the beginning of the text in the next animation phase.
For example, if my text is:
"And I think to myself what a wonderful world"
, and in a normal single-line+ellipsize TextView configuration it will look like:
[Beginning of TextView]And I think to myself wh...[End of TextView]
Then I want the text to start animating from left to right, until the whole text is shown, and then again (after a certain margin to the beginning of the text).
What is the simplest way to do this? I've looked for it but couldn't find anything promising.
You can add
android:scrollHorizontally="true"
android:ellipsize="marquee"
to your TextView
Note: for it to work, you have to select it in your code:
textView.setSelected(true);
Of course if you need something more customizable and elaborate this may not suits you.
Related
My designer has given me the layout spec. as shown in image, so i have to give a exact 20dp gap between first TextView(Verification Code Resent) and second TextView(Please check your text message...) but their is always a default padding for TextView that increase the gap between these two TextViews, i want to know is it possible to give exact 20dp margin between these textview ,if not does my desiner need to make some changes in layout spec, i'm confused please help me..
You can use android:includeFontPadding="false" in your XML for the TextViews.
As an alternative, you can set setIncludeFontPadding (false) on the TextView in your Java code.
I have an app in which the main view is a PopupWindow with a couple of ImageViews and an EditText on top of them. My problem is when I enter a very long text and the text box expands down and pushing the image views out of the view and I can't see them, and in order to see them back I need to delete some text.
What is the proper way of overcoming this?
thanks.
try to add into the XML something like that:
android:maxLines = "5"
android:scrollbars = "vertical"
Perhaps enclosing your LinearLayout of the PopupWindow in a ScrollView could help. LinearLayout does not allow for scrolling, if you are using it.
EDIT: In regards to the other answers, these will also work, but if you are intending to allow the user to enter as much text as they want, it may not be the best solution
See This question for more details
This should limit the height of the EditText, so even if the user types a long book in there, the field will keep its height limited to one line.
android:maxLines="1"
To limit the text to just one line, you can use this instead:
android:singleLine="true"
I have an listview and I need help with it. I'd like to keep the text in one "row" if would call it that.
So what I mean is, it doesnt matter how long the text is, if it's longer than the "witdh" then instead of showing the full text on two "rows" it should just fill that witdh and like, end it with ... or something else. The purpose of this is ofcourse so that all my rows in the listview are of the same size, or else it looks rlly amateurish and cheap ..
How can I do this?
Thanks for help!
Give the TextView that holds the long text following attributes
android:ellipsize="end"
android:singleLine="true"
This will ensure that long text is displayed in a single line end with "..." at the end.
Found in android doc: http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize
I am using and EditText to display my app's EULA. The EditText is marked singleLine=false and enabled = false.
When I ev.setText='....', the text appears slightly shifted 1 and 1/2 characters to the left plus down 1 and 1/2 lines. That is, the text is not registered/displayed properly to the top left corner. Any ideas?
Why an EditText? Seems like a TextView would be the more proper vehicle to display that.
As for the text position, it sounds like you have padding (or margins, or both) specified in the XML.
The following code works:
myEtLoginEula.setEnabled(false);
myEtLoginEula.setVisibility(View.VISIBLE);
myEtLoginEula.setText(myJS.getString("EULAText").replace("<br>","\n") + "\n");
myEtLoginEula.setScroller(new Scroller(getBaseContext()));
myEtLoginEula.setVerticalScrollBarEnabled(true);
myEtLoginEula.setMovementMethod(new ScrollingMovementMethod());
I was previously setting the text, .setText(myJS...) after the .setMovementMethod. It does not like that. I had originally obtained all this months back from another SO question regarding scrolling. Seems to work now. I will revisit TextViewinstead of EditTextas well. Thanks for your patience as I am newbie to SO responding!
I am having a strange issue, the words are cutting inside EDITTEXT i have set an image as background. Plz help me... for example here ffsds, is being cut, I want it to shift to bit right so that it doesnt get cut.
Increase paddingLeft value of edit text.
...
android:paddingLeft="100dp"
...
in xml layout.
Increasing the left padding is the easy solution. But if this smiley image is always on the left of the edittext, you can set the image by using the attribute android:drawableLeft on the edittext.