Jane strike
Jane strike

Reputation: 1

textview doesn't wraps correctly?

Two TextView

I've two textviews aligned horizontally. when the second TextView becomes longer it wraps to the next line incorrectly. I want it to start the text from the beginning of the layout instead of just below the TextView.

I've tried flow layout but it wrap all the text to the bottom rather than wrapping just the additional text.

FlowLayout

What I want :

What I want photo

The reason I want two TextView is because I'm working on Drag and Drop quiz, so when the user drags the answer to the textview it will change it's content "setText(answer)" to be the answer. Thank you for helping Drag and drop image

Upvotes: 0

Views: 92

Answers (3)

Mohit
Mohit

Reputation: 144

Instead of two textViews, take two string variables and work on them. in the end, just concatenate two strings and display it in the textView.

In order to give it look and feel of two different textViews, you can either use html format, or spannable text.

We might be able to help understand your problem better if you can explain the actual scenario, and why two textViews are necessary.

Upvotes: 0

Tom Alabaster
Tom Alabaster

Reputation: 975

I'm not sure this is possible. It sounds like an awkward way of going about something quite simple.

My solution would be to have 1 TextView, and join the two strings together that would otherwise be in separate TextViews.

Upvotes: 0

S.Elaiotrivaris
S.Elaiotrivaris

Reputation: 206

I don't think that this is possible. You can always use string with arguments to achieve that.

e.g.

<string name="test_string">%1$s %2$s</string>

and then

getString(R.string.test_string, "text view one text", "text view two text")

Upvotes: 2

Related Questions