Try this :
1) In xml:-
<com.google.android.gms.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="150dip"
android:background="@android:color/white" />
2) In Activity:-
private GoogleMap mMap;
private MapView mMapView;
private boolean mMapViewExpanded = false;
mMapView = (MapView)findViewById(R.id.map_view);
mMap = mMapView.getMap();
mMap.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng point) {
animateMapView();
}
});
private void animateMapView() {
Logging.d(LOG_TAG, "CLICKED ON THE MAPVIEW");
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mMapView.getLayoutParams();
ResizeAnimation a = new ResizeAnimation(mMapView);
a.setDuration(250);
if (!getMapViewStatus()) {
mMapViewExpanded = true;
a.setParams(lp.height, dpToPx(getResources(), 300));
} else {
mMapViewExpanded = false;
a.setParams(lp.height, dpToPx(getResources(), 150));
}
mMapView.startAnimation(a);
}
private boolean getMapViewStatus() {
return mMapViewExpanded;
}
public int dpToPx(Resources res, int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics());
}
3) ResizeAnimation.java
public class ResizeAnimation extends Animation {
private int startHeight;
private int deltaHeight; // distance between start and end height
private View view;
/**
* constructor, do not forget to use the setParams(int, int) method before
* starting the animation
*
* @param v
*/
public ResizeAnimation(View v) {
this.view = v;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
view.getLayoutParams().height = (int) (startHeight + deltaHeight * interpolatedTime);
view.requestLayout();
}
/**
* set the starting and ending height for the resize animation starting
* height is usually the views current height, the end height is the height
* we want to reach after the animation is completed
*
* @param start
* height in pixels
* @param end
* height in pixels
*/
public void setParams(int start, int end) {
this.startHeight = start;
deltaHeight = end - startHeight;
}
/**
* set the duration for the hideshowanimation
*/
@Override
public void setDuration(long durationMillis) {
super.setDuration(durationMillis);
}
@Override
public boolean willChangeBounds() {
return true;
}
}
RelativeLayout Rl = (RelativeLayout) findViewById(R.id.relativelayout); RelativeLayout.LayoutParams layout_description = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT or YourUserDefinedwidth, RelativeLayout.LayoutParams.FILL_PARENT or YourUserDefinedHeight); Rl.setLayoutParams(layout_description);
– Ramakrishna