2

I mean something like what's asked here. I see people are suggesting using a staticlayout, but I don't understand how that solves it. I've also seen people suggesting webviews, but that seems stupid. I want a reusable View that can take XML input, and I should be able to use it in a ListView without making a webview inside each row. Ideas?

I've got this working by drawing everything myself, but I'm stuck at the words breaking issue.

I'd also like the image to be clickable, which I've kinda got already, but with the same functionality of the statelistdrawables we're all used to. Do I have to maintain image state in the view and change which drawable to draw based on that?

Community
  • 1
  • 1
AmITheRWord
  • 1,363
  • 2
  • 14
  • 36

1 Answers1

0

Perhaps try this answer, using a WebView.

Edit: after playing with getLineCount(), getLineLastVisible(), and various ellipsis settings, I've come to the conclusion that this was not meant to be.

In theory you could use getLineCount() and getLineLastVisible() to measure the text that fit in the view and populate a second overflow view appropriately. Unfortunately these don't actually have anything to do with the visible (on screen) portion of the TextView, and a TextView that is only able to show 3 lines will happily report many more lines in getLineCount() if there are lines hidden.

I think a general solution to this problem is going to require hacking together your own ViewGroup (it would contain an inset image or the View to layout around) from pieces of TextView.java.

Short answer: This is not easy to do given the current framework.

Community
  • 1
  • 1
Matthew
  • 44,826
  • 10
  • 98
  • 87
  • Even though I specifically state that I do not want to use a WebView? I don't know how I'd make the icon clickable in the webview, and make it open a new activity. I don't think it's very efficient having up to 50 WebViews inside a list. I don't know if it's possible to turn off the WebView's default behaviour when it comes to scrolling and zooming. We're supposed to be able to build upon and extend Views, and I don't think a WebView is the best solution for this, even if it does the job half-assedly. – AmITheRWord Mar 01 '11 at 16:37
  • I think you're right about having to create my own View or ViewGroup. I just wish there was more documentation or people doing that more often so I'd have a starting off point. It's what I've started to do, which you can see in the screen shot. Guess I'll just have to continue down that path. I'll leave the question open for a little while longer, though, if someone has any experience in creating custom views. – AmITheRWord Mar 01 '11 at 22:18