Ellipsized TextView with suffix - android

I have text that may be ellipsized in two lines. But no matter how many lines it takes, I need that some additional (short but length may vary) text would ALWAYS be fully visible at the end of previous text.
Here are three cases representing my problem:
How can I achieve this? I tried measuring text length and splitting it into two TextViews but it's not accurate enough and also hits performance badly.

Related

Android text alignment based on character's index

I have a seemingly simple task in Android, which turned out to be quite complex.
I have multiple strings, and I want each string to be centered based on a character in a specific position in that string. For example "azcde" should be centered on a character in index 1 ("z" in this case), "trxdsf" should be centered on a character in index 2 ("x" in this case), ...
Below is an example.
The problem is that characters vary in size (e.g. "i" is much thinner than "m")...
Can this be done in TextView or custom View?

Calculate text layout with StaticLayout without allow word-wrapping

Is there some way to use StaticLayout without doing automatic word wrapping? If the text includes newlines I want them to break up the paragraphs, but I don't want it wrap at a given width. It's not giving sane results, especially with Center/Right aligned text.
Is there a way to simply turn off the auto-wrapping on StaticLayout?
More details. I use getDesiredWidth to calculate a width and then use this as the wrap width for a new StaticLayout. This prevents auto-wrapping, but it also seems to turn off explicit wrapping as. GetLineCount returns 1 for text that actually has multiple-lines.

in a paragraph how to find the each line's first and last word programmatically in android textview

I want to find the line's first and last word of a paragraph.
sample :
My country is Turkey.I love my country very much.
There are four season in my country in a year. Each
one has 3 month. That's the place where every one
live *in*.
In such a paragraph, I want the words that is in Bold.This paragraph is in textview
and the code must take care of the width of textview.If width changes, first and last words also changes, and algorithm must find them.
If you help, I'll be glad.
I'm not sure how android handles the actual placement of text with resizes and all that. I really doubt that it adds in tab carriages and newlines to the text to display them, but if it does, you could use regex to find that. Or regex with the line anchors. Take a look at this, see if it helps:
http://www.regular-expressions.info/anchors.html

Two columns of autowrapped text

I need to lay out several (for example, two) labels (textviews) as columns. The texts can be longer altogether than one screen line and may not contain line breaks, so they need to be formatted (wrapped) to fit the screen width.
I can arrange labels as columns if they are shorter altogether than a screen line. I can wrap a text to fit the screen if there’s only one column. But if the texts are longer and there are more than one column, I cannot achieve what I want, because the first column always fills the whole screen width.
I tried to do this via xml-markup. I tried a lot of markups using LinearLayout, TableLayout and RelativeLayout. All didn’t work. Maybe, I didn’t use them properly.
I can imagine the ways using code to manually calculate views’ widths, but haven’t tried. Any solution is welcome, but using markup only are preffered.

Calculating Android TextView's text capacity

I have TextView with height and width as fill parent. Is it possible to find out how many characters can this layout hold?
Do you mean how many characters can be entered into the textview and still be fully visible without scrolling? For proportional fonts, that will depend on the specific characters typed, including where the line break opportunities are. I don't think there's a simple way to compute that.

Categories

Resources