What appeared to be a simple requirement is becoming quite a painful process. I need an AppWidget to show some (usually multi-line) text - the text will vary in size, and may be longer than the view allows, so needs ellipsizing in that case. The view will also support resizable widgets in Android v3.1, which again requires that the widget be able to dynamically support content of varying sizes correctly. Easy, you'd think? And if it was a single line TextView, I think it would be...
So initially I created a single TextView, set the properties to ellipsize it when the text doesn't fit, and came across the bug that means this doesn't work - the text only wraps across two lines.
I then grabbed an open source custom view that ellipsizes correctly with multiple lines and it works fine, but only in an activity. I forgot that AppWidget limits what Views can go in a widget, so this also fails ("Class not allowed to be inflated"). I see no way to use this custom view.
So... the best solution I can think of is to add a series of single-row TextViews to the widget, and iterate through substrings until I find the length that fits in each row, before moving on to the next. i.e. manually render/measure/render the text. There are many downsides to this approach.
Is there a better way to get multi-line ellipsized text into an AppWidget?