Alex Gittemeier
Alex Gittemeier

Reputation: 5373

How do I force a TextView to be at least one line tall even when blank?

Consider this list row for example:

┏━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       │ Primary Text                ┃
┃  IMG  │                             ┃
┃       │ Secondary Text              ┃
┗━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

I would like to know how to keep the secondary text box from collapsing on itself when its blank. The image may or may not be taller than the primary text, and both textboxes may span multiple lines.

Upvotes: 0

Views: 447

Answers (2)

Hareshkumar Chhelana
Hareshkumar Chhelana

Reputation: 24848

// try this attribute on Secondary TextView
android:minLines="1"

Upvotes: 1

Alex Gittemeier
Alex Gittemeier

Reputation: 5373

One way to get around this issue it to use a non-breaking space in the secondary text when it would otherwise be blank. ('\u0240')

Upvotes: 0

Related Questions