I'm trying to resize my MapView when a user clicks a certain button (ie - go from a mapview a quarter of the screen size to full screen size) however I do not know how to do it!
I've tried mMapView.setLayoutParams(new MapView.LayoutParams(250, 250, 0, 0, 6));
but that only gives me errors (ClassCastException).
I can't think of anything else (and searching has not come up with much).
Try this:
MapView map = new MapView(this, "");
map.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
map.setLayoutParams(new ViewGroup.LayoutParams(200, 200));
By the way as a general rule, never use absolute positioning (250 pixels) to do anything in Android - it'll cause problems when used on different devices. Use relative layouts, or at the very least device independent pixels (dip). So for example you could set the layout_width to wrap_content, the layout_weight of the MapView to 1 (so it stetches to fill the available space), and then place another UI element to its side, taking up some of the space, and the map will then reduce in size.