I've got a tiled pan-n-zoom component that uses several FrameLayouts to 
position image tiles (that scale), markers (that move, but don't scale) and 
controls (which neither move nor scale). It works fine.

Markers are positioned in a FrameLayout with topMargin and leftMargin. So 
far so good.

When a marker is touched, I need to open a little popup, at the same 
position as the marker that was touched *but offset by the dimensions of 
the popup*. That's to say that if the popup is 100 pixels wide and 50 
pixels tall, and the marker touched was at 800 x and 1100 y, the popup 
should be at 750 x (postion of marker minus half the width of the popup) 
and 1050 y (position of the marker minus the full height of the popup). The 
effect is like a tooltip - a little nub points down at the marker, etc. 
 the ideal logic would be "x position is layoutParams.leftMargin - 
(getWidth() / 2), y position is layoutParams.topMargin - getHeight() - but 
obviously that wouldn't work.

the popups should be in a separate layer (viewgroup) than the markers.

The popup dimensions are flexible, based on the text to be displayed, and 
need to be calculated.

Obviously the dimensions aren't available until after layout happens.  It 
looks like I can get the dimensions of the children during onLayout and the 
second pass of onMeasure, but if I update and re-assign LayoutParams (with 
modified top/leftMargins), during onLayout, sounds like an infinite loop. 
 I tried setting a flag so I could catch just the first pass, but this 
failed - I don't really expect this to be the right approach in any case.

I also tried getting the dimensions during onLayout, then in onDraw using 
canvas.translate(offsetX, offsetY), but this caused it to be "clipped" and 
drawn outside the available region.

What's the best way to get these dimensions and position these views 
accordingly?

(should mention that a RelativeLayout is not an option - the popups should 
be in a different viewgroup than the markers).

TYIA.

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