I have a Google mapview in the corner of the screen. I want to add an event that makes it go fullscreen with a button on the map interface, and then small screen again with the same button. Any ideas??
Android v4.0.4 Google Map API V2
You could do this by 2 way:
create a new Activity
that on the press of a button will start of and will include a full screen map. in this activity create the same button that will bring you back to your original Activity
.
you can programaticly change the Layout width a length of you MapFragment
in the same window.
second option will be better as you would avoid the screen flickering of new activity loading.
UPDATE:
regarding the second option here is a code i wrote to enlarge map onClick of the map see if this helps you:
@Override
public void onMapClick(LatLng point)
{
LinearLayout mapFrameLayout = (LinearLayout)findViewById(R.id.mapFrameLayout);
if (!isMapOpen)
{
LinearLayout.LayoutParams fullMapParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
if (!isDetailsOpen)
{
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.hide(closedDetailsFragment).commit();
mapFrameLayout.setLayoutParams(fullMapParams);
isMapOpen = true;
isDetailsOpenWhenOpenedMap = false;
}
else
{
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.hide(openedDetailsFragment).commit();
mapFrameLayout.setLayoutParams(fullMapParams);
isMapOpen = true;
isDetailsOpenWhenOpenedMap = true;
}
}
else
{
LinearLayout.LayoutParams defaultMapparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 280);
mapFrameLayout.setLayoutParams(defaultMapparams);
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (isDetailsOpenWhenOpenedMap)
{
fragmentTransaction.show(openedDetailsFragment).commit();
}
else
{
fragmentTransaction.show(closedDetailsFragment).commit();
}
isMapOpen = false;
}
}
as you see i change the size of the FrameLayout
where the map sits, you can put in the same layout your button and place it on the right|top corner for example. when your map will stretch the button will still be at the same right|top corner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With