Saturday, April 11, 2009

Properties of LinearLayouts

I'm jotting this down so that I don't get stuck on it; it's no kind of show-stopper and can be changed later. I've been simplifying all of the interfaces in the OIWL lately, and I'm now trying to decide what to do with LinearLayout. Specifically, I'm trying to determine what properties linear layouts need to store. Of course they need to know the position and sizes of each of their component boxes, but what else? What about the padding (distance from border to contained widget) within those boxes? What about the horizontal and vertical alignment within each box? What about margins (spacing between each box)?

Each of these could be simulated with other Widgets: For padding, perhaps create simple a Padder widget or something that can be a layout that manages a single Widget and stores padding from each side. For alignment, a similar Aligner widget or something that stores horizontal and vertical alignment could be employed. Might be an easy way to get drawn borders as well. For margins, we could simply put a Spacer widget in a box between a given set of boxes.

The downside to using additional widgets is that each Widget adds overhead to both the memory footprint and rendering time of a given screen. I don't know whether the overhead on either of these is significant enough to merit worry. For now though, I will maintain simple-as-possible widgets, which means LinearLayouts will be without alignment and padding properties. By default, all widgets in a LinearLayout will be centered vertically and horizontally within a box (arbitrary as well).