In my application, I have something similar in appearance to shortcuts in the GMail application interface. For those who may not know, they look like this (these shortcuts are shortcuts):
To achieve a similar effect, I use draw-draw of nine patches - for each label I create a TextView and assign it the ability to draw. This is a simple solution, but I don't like it. It is not elegant, it is rather slow, as shown by the profiler, and I just don't think this is the right way to do this.
I redesigned the user interface to make it more "ICS-y", so I removed the rounded corners from the shortcuts. And I thought how to replace the 9-patch solution. The most obvious is to use BackgroundColorSpan. But he has one, small flaw. I want my labels to have some kind of addition. With the help of the drawings, this was easy to achieve. With spans it is more difficult. To make the horizontal fill, I can simply add spaces at the beginning and end of the line. But how to increase vertical filling? To clarify the situation, this is a screenshot of the label with BackgroundColorSpan:
I want to make the colored parts above and below the text larger. I think I should use some MetricAffectingSpan, but I could not figure out which one. Or maybe I should write my own? Or, finally, maybe the gaps are simply not able to satisfy my needs, and I have to stay with the images or create a canvas and manually draw everything, as in the GMail application?
user1234567
source share