font diaplay half when TextView is too short - android

the textView's height and width is fixed.
when the length of string is longer than textview,the last-line text sometimes display half.
I want,when the last-line text can't display complete,discard it.how to realize?

It sounds to me like you already have ellipsize enabled, and that's why you're only getting "half" the last line.
Depending on what you're trying to achieve, you can-
Remove ellipsize settings and suffer
the string cut-off.
Resize your textview so that all the
text will fit.
Change your font size so that all the
text will fit.
StaticLayout has a way of detecting if the last line will cut off (using getEllipsisCount(line)) which is supposedly used internally by TextView, but I've had no luck using that to detect when a TextView is being cut off (see post).
If this doesn't help, please give us a better picture of what you're doing.

Related

Fit the text size in textview

I have a function that generates a random number. Then, I place the number in a TextView. When the number is a single digit, it fills the TextView perfectly, but when the number is two digits or more, it only shows a single digit because the text size is huge.
How do I automatically fit the text size to the TextView? Something like reduce the text size so that all the number will be shown in the TextView.
I don't have enough reputation to comment so I must abuse an answer. No need to reduce the number's size. Just make sure the TextView is set to wrap_context in the layout:width property and also possibly the layout:height property, that should fix your formatting problem.

set fullstop (.) center_vertical with textview android

How to set dot in vertically center of textview example (. Set .) , I want both dots in vertically center of set text. i have been tried with gravity center but didnt get any success, You can refer attached image where dot show after just now with very light color, i want same , so please suggest how to achieve this
Use a bullet character, \u00b7
There is no way you can do this in the way you are trying to do it.
Remember, fullstop may look as just a dot, but in reality, there is empty space above the dot. From bitmap perspective, it is as tall as any other character.
You may, however, try below 2 approaches:
Use different character instead of fullstop. e.g. "\u00B7". It looks like ·set·
Change the font size of just . (not possible in simple textview, AFAIK. Possible in rich text edit boxes.)
Set margin from top in negative(like -10dp).

Android: Detect where textView (with Ellipsize=none) would have ellipsed, and get the extra text

In my Android app, I have a textView that has a limited length and a string that is much larger. I need to display as much of the string in the textView as possible and then detect exactly what text is left over. The tricky part is that unlike this previous post (How to get the ellipsized text in a TextView), I can't have an ellipse show in the textView. The example in that post relies on the ellipse.
Does anyone know of a way to either get the overflow text without relying on the ellipse (.getEllipsisStart()), or to hide the ellipse from appearing?

Text Fit In TextView

I have a TextView that is going to display one single sentence.
This sentence could be shorter or longer, up to 200 characters for example, but could be more.
I am trying to fit the size of the TextView dynamically according to the text that will be written, but nothing that I have found so far works for me.
I have tried the Auto Scale TextView Text to Fit within Bounds but it's not perfect for my needs as it adapts the text to a very small size and writing two lines, leaving a huge blank space on top and under the text.
EDIT: I see that in phones this solution works perfect. However, when I test in a tablet, it does not increase the text size to fill as much as possible. I am not sure, but I think it only decreases to fit. Please, correct me if I am wrong.
Has somebody tried a different solution?
You could try the AutoScale TextView third-party widget.

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