grouping texts plus images + round edges in android
i was requested to make in android a view that groups several items like checkboxes or text views in vertical rows, separated by transparent dividers while the background is with a certain alpha level and the edges are round.
I thought of two solutions and i hope for some feedback on good\bad or other solutions if you got'em.
- just use regualr linear layout but have a single style A that uses a 9 patch as background, includes padding,margins and whatever i need to make it look like what i want. i then create another style A.up and A.down that represents the upper most and lower most items that will use a different 9-path with round corners.
- inherit from linear layout, in the onMeasure and layo开发者_如何学PythonutChildren add to all the children some kind of space between them, i can create new attribute for it that can be customized in a style. i can override the dispatchDraw to paint the background for each view before it draws so i can paint my round borders, my only demand will be that each View added to this layout will have to be with transparent background.
So what do you think ?
Eventually i decided to use a List with customized divider. It looks good, however a list got a very nasty bug when it comes down to items with states like buttons and clickable textViews,
- you get no focus for the item and don't see the ornage bar
- you don't seem to get the evnets flowing to the children of the View in the list.
I'm notsure how to resolve that one, i've seen numerous mails about it in the developres mailing list and here, most saying don't put statefull objects in a list. So it mist not be the solution for me. Nest thing i'll try is extending the normal layouts to have a bar in their bottom and use regualr linear layout with round corners drawable.
精彩评论