Some additional information:
I overrode the drawable methods and found onBoundsChange() was being called 
on return to the map activity. I suppose there is a redraw of some sort, 
but not sure where. At this time the bounds are different.

I have a workaround... but I would still like an answer as to why this is 
happening. The workaround is to override the draw method, and set the 
bounds (to center bottom) whenever the draw method is called. Here is the 
code:

    @Override
    public void draw(Canvas canvas) {
      int dWidth = getIntrinsicWidth();
      int dHeight = getIntrinsicHeight();
      setBounds(-dWidth / 2, -dHeight, dWidth / 2, 0);
      super.draw(canvas);
    }


On Sunday, September 23, 2012 7:18:55 PM UTC-4, Na Yang wrote:
>
> I have a MapView, with various markers on it. On entering the MapActivity 
> the first time, I set the bounds of drawables set on the markers, and 
> everything appears fine. The markers and shadows all appear correctly. But 
> when I click over to another activity, and return, the shadows, or the 
> markers are no longer bound correctly. Sometimes its only some of the 
> markers that are affected. Can anyone tell me what is going on here? Here 
> is some code. Below is where I set the bounds on the marker drawable:
>
>     InputStream is = assetManager.open(imageName);
>     drawable = Drawable.createFromStream(is, null);
>     int width = drawable.getIntrinsicWidth();
>     int height = drawable.getIntrinsicHeight();
>     drawable.setBounds(-width / 2, -height, width - (width / 2), 0);
>
>
> And here is how I create/add the overlay item to the map:
>
>     GeoPoint point = createGeoPoint(lat, lon);
>     OverlayItem overlayItem = new OverlayItem(point, character.get_id(), 
> "");
>     Drawable image = drawable;
>     overlayItem.setMarker(image);
>     itemizedOverlay.addOverlay(overlayItem);
>
> From what I can tell, the overlays are not being re-added to the map, this 
> is simply a redraw after an onResume() event. Any ideas?
>
> In addition, only images of the type tapped move, and its not the shadow, 
> but the image that moves. So, of there are x images of type A, and y images 
> of type B, and I tap on any image of type A, all images of type A are 
> misaligned with their shadows when I return to the MapActivity, while all 
> images of type B are still properly aligned.
>
> This seems to be exclusive to the setMarker() method of setting the image, 
> as using the default marker does not exhibit this problem.
>

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