Wrap the content of text view in java code in android – Education Career Blog

I am dynamically creating layout and text view in android. If the text view content is large, how to wrap the content of text view dynamically?


To make a TextView wrap it’s content you have to specify that it should not be treated as ‘single line’. You can do this in it’s XML properties or dynamically by callig:

public void setSingleLine (boolean singleLine)

If true, sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions. Note that calling this with false restores default conditions, not necessarily those that were in effect prior to calling it with true.

Related XML Attributes

  • android:singleLine

An example:



Leave a Comment