Position views at specific location?
Is there a way to place widgets / views on the screen at any specific position required?
Something like a calendar with daily events that could overlap. e.g. if every hour in a day is represented by 1 hour and there are 2 appointments that overlap partially (say 12:00 - 12:30 and 12:20 - 01:00) this would be drawn in the same row but the 12:20 one positioned slightly below the first.
Also there may be views (Image/TextView) that need to span 2 rows (i.e. 12:30 - 1:30).
I think a SurfaceView is one option (is this efficient?) but am not sure if there is some better layout that could be used.
We could use a TableLayout for the hour rows but not sure if t开发者_如何学Gohere is a way to place overlapping widgets on this?
TIA
Official answer: create your own layout manager class that implements the rules you want.
Easier but slightly messy answer: use a RelativeLayout
and margins to position your widgets. To have widgets overlap, have the one that should be on top be a later child in the layout (e.g., farther down the list of child XML elements in a layout file).
What you don't want: AbsoluteLayout
. This is deprecated.
精彩评论