I've used three TextViews. one for "-", second for the empty field and the third for the rest of the sentence.
enter image description here
but the problem is that, this is quite buggy and when I add more text to the last TextView (sentence TextView) the text wraps to the bottom of the last TextView instead of the first TextView. Help Please ):
enter image description here
You can use one TextView and at runtime set text of it like below:
myTextView.setText("-"+" " + your text);
That is all thing you need.
Related
I have a TextView and I set text which I receive from Backend.
the text is either from 1 to 3 words.
Maximum the textview can be 2 lines.
I am using setAutoSizeTextTypeUniformWithConfiguration
and text.breakStrategy = LineBreaker.BREAK_STRATEGY_SIMPLE
And I don't have any success.
wondering is it possible if the text is single word I don't want to split it. I would like to have it in single line with small textSize. if the text is 2 words and long I am fine to show it in 2 lines. The problem is it always breaks the word in 2 lines if it is long while I don't want.
The only solution that comes to my mind is before setting the text to a textview, check whether text has spaces in it.
If it has not that that means it's a single word, so set ptogrammatically maxlines to 1, otherwise set maxlines to 2.
EDIT: I missed text size part. I use this library for autoresizing and it worked so far https://github.com/jivimberg/AutoResizeTextView
it's automatically handled in androidx.appcompat.widget.AppCompatEditText and just set android:maxLines="2"
remove all other properties you set
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
Suppose I have TextView and I want to change color of some part in it. Like this
And I must set OnclickListener on text " Terms Of Use ", so How can I do that but using two textViews. Thanks
Regards
Use a simple Checkbox with no text, and for text clicking event
this is what you are looking for Spannable
You can youse HTML in TextView:
myTextView.setText(Html.fromHtml("<h2>Test</h2>"));
I have a textview with fixed height. I want to set a long text, but text comes at the last line getting cut by half, I want to avoid it and want to show a continuation symbol. I am giving an image here, I wan to achieve it like in the image.
Use the ellipsize attribute of TextView. By setting :
<TextView
....
android:ellipsize="end">
</TextView>
if the text is longer than your TextView you will have dots(...) at the end of the TextView.
Two line of string only possible to do like this. set ellipsize = end in text view properties.
you should use \n and special symbols from google code.
I want to access text of particular line in a multi-line TextView. Any suggestions on how I could do this?
Fetch the Layout (android.text.Layout) of the TextView by calling mTextView.getLayout(); There you can for instance use the getLineStart or getLineEnd methods to get the offset of the text. That combined with getText and used using normal String operations should probably be enough for u!
By default, text view is multi line. Set the text with new line characters for ex. "First line \nSecond line".
Another option is listed here : https://stackoverflow.com/questions/2610280/how-to-get-multi-line-text-on-a-button-in-android