D
D
Dmitry2016-08-29 14:13:11
Android
Dmitry, 2016-08-29 14:13:11

How to count lines before displaying TextView?

Does anyone know how to count the number of lines before displaying a TextView?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Perelygin, 2016-08-30
@Scotik

Wash something like this:

TextPaint paint = new TextPaint();
Rect bounds = new Rect();
paint.setTextSize();
paint.setStyle();
paint.getTextBounds(testString, 0, testString.length(), bounds);
int length= (int) Math.ceil((float) bounds.width() / currentSize);
                                  //currentSize - ширина TextView учитывая падинги всякие

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question