Kushal
Kushal

Reputation: 98

Is it possible to treat two lines as one?

Lines:

 This is the first line and it is long line1.
 This is the second line and it is long line2.

Obviously, these two lines contain "\n" at the end.

But when the device screen is small, at some point.

Default Output:

  This is the first line and
  it is long line1.
  This is the second line and
  it is long line2.

Expected Output:

  This is the first line and
  This is the second line and
  it is long line1.
  it is long line2.

Besides using ReplacementSpan to draw first line above the second line, as a workaround I was wondering if it is possible to treat those two lines as one. What options do I have to achieve such output?

Upvotes: 0

Views: 84

Answers (1)

Joop Eggen
Joop Eggen

Reputation: 109613

The "logical" solution would be to replace the first line break \n by a space.

But in your case it seems you want a horizontally scrolling text view:

<TextView 
    android:lines="2"
    android:scrollHorizontally="true"
    android:singleLine="true" ... />

I am not sure about the lines and singleLine attribute.

Upvotes: 1

Related Questions