I have a horizontal LinearLayout
containing a TextView
followed by a Spinner
next to it. This LinearLayout
is dynamically
I had the same problem and found a handy solution. I get the number of lines of the TextView after rendering and set the height according to the number of lines. Here is the code.
TextView textView = (TextView) layout.findViewById(R.id.textView);
textView.setText(this.text);
textView.post(new Runnable() {
@Override
public void run() {
int linesCount = textView.getLineCount();
textView.setLines(linesCount);
}
});