I am encountering a rather specific problem. I have a MapFragment
in my Activity
in a FrameLayout
so that the Toolbar
overlays the map. This because the Toolbar
needs to be animated off the screen sometimes and if it doesn't overlay the map there will be a gap.
Now when a device doesn't have valid Google Play Services
the MapFragment
will display a message and a button to update the services by default. My problem is that this message is shown at the top left corner of the map, which is below the Toolbar
.
Does anyone have an idea on how to tackle this problem? Maybe check the validity of the Google Play Services
myself and create some padding when it is not valid? Or is there an easy solution like setting some kind of gravity on the map so that the update message is centered.
I appreciate the help.
You can add padding around the edges of the map using the GoogleMap.setPadding() method. Or create custom alertDialog which shows to user information about Google Play Services
example with dialog
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int code = api.isGooglePlayServicesAvailable(activity);
if (code == ConnectionResult.SUCCESS) {
//
} else {
AlertDialog alertDialog =
new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle).setMessage(
"You need to download Google Play Services in order to use this part of the application")
.create();
alertDialog.show();
}