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 function开发者_如何学Cality 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?
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.
精彩评论