Found a couple of online solutions for Auto Scale TextView Text to Fit within Bounds

But the problem is that the transfer of text to the next line is carried out independently (randomly) and the symbol \n is not perceived as either. If for each line you create a separate TextView, then each line has a different font size depending on the length. Ie if I want to print a verse, then in each line there will be a different font size depending on the length of the line. Are there any other ways? Can you make an auto scale to the entire layout in which the lines are? I did not find a way :(. And by the way, neither solution works with Russian characters

enter image description here

Closed due to the fact that the question is too general for the participants of Shwarz Andrei , user194374, YuriSPb , Vartlok , Saidolim 5 Apr '16 at 15:04 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Not quite clear the problem. Can wrap_content suit wrap_content for width and height and line wrapping with the <br> tag and setting text via Html.fromHtml() ? - Yuriy SPb
  • Actually I have two Layout . In one phone in another information from the user. As you can see, all TextView have different fonts and it looks awful. The font is changed so that all the text got into the line. - Bogdan Shulga
  • one
    And you do not like the usual behavior when there is a line break? And if, instead of a line break, the text at the end will be removed and replaced with dots? Type длинный-длинный тек... ? - Yuriy SPb
  • one
    Because There is little space on the phones, but there are still custom test sizes that are installed at the system level, I think it is impossible to make text on all screens so that all users are comfortable and beautiful. I would solve the problem by setting one font size everywhere, one TextView per line-number, shorten the long text with dots (this is the android:ellipsize ) and, if I click on the number, android:ellipsize it in a separate dialog. - JuriySPb
  • one
    As far as I know, yes, it will not work. Moreover, it is also voracious and lag everything will start. - Yuriy SPb

1 answer 1

TextView in Android bit controversial. If you want to format the text as you like - use WebView . Just feed the formatted String / text file and enjoy the result:

 String data = ""<html>...</html>""; webview.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null); 
  • The variant is interesting to think about. And if the webview is dynamically minus. Does the text formatting remain? - Bogdan Shulga