Search code examples
androidgoogle-mapssetbounds

How do I do boundCenterBottom with setBounds in android?


I'm making an app that sets a pin down on a certain location. I would like the location to be at the bottom center of the image. I'm using the setBounds method to create the bound but I'm not sure how to make it "boundCenterBottom"

            drawable = Maps.this.getResources().getDrawable(pincolorstar[ImTracking.pList.get(k).getPosition()]);
  // right now the bounds are putting the marker way off target
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
//more stuff

            OverlayItem overlayitem = new OverlayItem(myPoint, mList.get(i).getName(), mList.get(i).getTime());
           overlayitem.setMarker(drawable);

Solution

  • I'm not sure this will work and can't check it right now, but try:

    int dWidth = drawable.getIntrinsicWidth();
    int dHeight = drawable.getIntrinsicHeight();
    drawable.setBounds(-dWidth / 2, -dHeight, dWidth / 2, 0);