What if the list view's content produces unequal margins in the horizontal and vertical directions? I don't think your requirement, as written, can handle this.
If equal horizontal and vertical margins weren't a requirement, I'd say make a FrameLayout with minimum margins (or padding), then set your list view to wrap_content / wrap_content, and layout_gravity to "center". That should come pretty close. Other than that, you might need to write your own ViewGroup subclass, perhaps starting by subclassing FrameLayout. -- Kostya 2011/6/12 Ted Hopp <ted.h...@gmail.com> > I have a rather involved requirement for a rather simple layout. I have an > activity with a single ListView floating in the middle of the screen with a > background margin of uniform width all around. So far no problem. Now I need > the margin to be as large as possible given the content of the ListView, but > always equal all around. Furthermore, if the ListView contents are higher > than the screen, then there needs to be a minimum margin (that is, the > margin cannot shrink to zero). Another way of stating the problem: the > ListView should be nominally sized to wrap_content, except it should then > expand in x or y as necessary to equalize the margins. > > Without the equal-all-around requirement, or without the > margin-as-large-as-possible requirement, this would all be fairly simple to > do using layout_weight. Is there a way to implement both requirements? (In > XML with stock UI elements, that is; I know I could do this in code.) > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en