android - TextView.setMaxLines not working? -


I have a screen in my app where I display some text and then there is a variable in a photo text length (sometimes Sometimes not at all, sometimes a lot), so I wanted to set it, so the text is not taken more than a few lines (but can be scrolled) so that enough space for the image below can be left.

My visual component for this part is programmatically created, and I have adjusted the code for the following (currently in my text-setting method, but this is the case if it is initial View-generation code)

  Public Zero Set Description (string description) {mTxtDescription.setText (Html.fromHtml (description)); MTxtDescription.setClickable (true); MTxtDescription.setMaxLines (5); MTxtDescription.setLines (5); // It does not matter! MTxtDescription.setSingleLine (wrong); MTxtDescription.setScrollbarFadingEnabled (true); MTxtDescription.setScrollBarStyle (vertical); MTxtDescription.setMovementMethod (ScrollingMovementMethod.getInstance ()); MTxtDescription.invalidate (); // There is no difference in connecting it ...}   

Although this does not work - long text still fills the whole screen and disappears due to pushing down to the height of the image How do I get text for no more than 0. 5th?

Try removing the call setSingleLine . And use setInputType (InputType.TYPE_TEXT_FLAG_MULTI_LINE) . This will also keep this call to ensure the setMaxLines and setLines calls

Note: Overrides settings for setLines setMaxLines and setMinLines .



Comments