views:

33

answers:

1

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.

  1. 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.
  2. inherit from linear layout, in the onMeasure and layoutChildren 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 ?

A: 

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,

  1. you get no focus for the item and don't see the ornage bar
  2. 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.

codeScriber
OK, change of plans, here is something that works and is relatively fast to create, but to be honest, most chances it'll be faster in code then xml, took the base idea from the android developer site table layout example.1. create linear layout with vertical orientation2. set the background to round rectangle drawable.3. i chose to put each line item in frame layout but it can be whatever layout you choose.4. use a <view> tag that fills the width and 1 pixel height as a separator.5. assin each line\view a style so you can manipulate it later on.
codeScriber