I had that a lot! I needed to have a dynamic layout of icons, that will act as GridView (so they may appear in more than one line), but the Text view needed to be inside a scroll view to enable scrolling for all of the layout.
The common approach for that is using ImageSpan with ClickableSpan on it. But this also has some issues:
- You need the TextView to enable clicks on the ClickableSpans.
- You can't really modify images when you're using ImageSpan. I needed to add padding between the images.
For the first problem I found this great subclass for TextView that enable ClickableSpans without messing with the touch hierarchy. meaning you can insert it inside ListView or GridView, and still using the "normal" OnItemClickListener for the rest of the clicks.
For the second Problem I've created a sub-class for image span that can also be set with padding (in pixel) to apply padding on the image.
No comments:
Post a Comment