I'm building an app that includes photo tagging.  In order to display
the tags on a tagged photo, I was looking for a layout that could
absolute position the tags over the image and allow them to be
clickable, etc.

Naturally, my first instinct was to look at AbsoluteLayout (I'm trying
to absolute position something, this just seems logical).  I
discovered that it was deprecated and came across all of these
StackOverflow answers and Android mailing list threads describing why
AbsoluteLayout is evil and how I'm a naughty child for wanting to use
it.  The argument boiled down to this: multiple screen sizes in
Android would make it so your layout would be difficult to maintain
and look like crap on different phones.  I would agree with that
assessment for most cases, and I can see how people may misuse an
AbsoluteLayout.

I think using the following technique, however, there is no better
layout to use than AbsoluteLayout.  My tags' coordinates are defined
in percentages rather than pixels.  At runtime, I get the width and
height of the image I'm overlaying, and calculate the pixel
coordinates of the tags.  The tags are then added to the
AbsoluteLayout using the calculated coordinates.  If the image expands
or shrinks on different sized screens, it won't matter because the
coordinates of the tags will scale along with it.

To avoid getting the rug pulled out from under me if AbsoluteLayout is
ever all of a sudden removed from the SDK, I ended up using a
FrameLayout and setting top and left margins (the exact same effect)
to position the tags.

So my question is this: if there is a case where AbsoluteLayout is the
best tool to use, why is it deprecated?

-- 
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

Reply via email to