arturh
arturh

Reputation: 469

Position a view after the last word of a multiline TextView

I would like to locate a view just after the last word of a (potentially) multi-line TextView.

For example, the TextView might be two lines, with the second line being about half as long as the TextView's width. How do I locate a View just after the last word?

Upvotes: 2

Views: 485

Answers (1)

Moritz
Moritz

Reputation: 10352

You can use a StaticLayout to measure the width of your text lines and place your other view at the absolute position of the the second line length.

Alternatively you could use HTML in your TextView to place some elements inside your view.

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));

Supported html tags: http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

Upvotes: 1

Related Questions