Reputation: 3102
I've created a transparent actionbar but the zoom controls and the word 'Google' are behind it. I have no clue how to adjust their location. The default Google Map app on Android phones has them raised above the bottom action bar. Is it possible to reposition the zoom controls and the word 'Google'?
I know you can enable/disable the controls with:
map.getUiSettings().setZoomControlsEnabled(true);
Upvotes: 14
Views: 17974
Reputation: 1665
You can accomplish this with the GoogleMap.setPadding() method (added in September 2013):
map.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
From the API docs:
This method allows you to define a visible region on the map, to signal to the map that portions of the map around the edges may be obscured, by setting padding on each of the four edges of the map. Map functions will be adapted to the padding. For example, the zoom controls, compass, copyright notices and Google logo will be moved to fit inside the defined region, camera movements will be relative to the center of the visible region, etc.
Also see the description of how padding works in GoogleMap.
Upvotes: 18
Reputation: 493
If you are doing this for map adjustment then use margin or padding on bottom only about 36dp
to 40dp
. Otherwise if you are using location on Map in center then use a property of camera such like:
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
It make focus on location at meddium of page.
This: mMap.getUiSettings().setZoomControlsEnabled(true);
gives you only Zoom level but not focus on location at meddium.
Upvotes: 0
Reputation: 952
Unfortunately there is no way to move the zoom controls provided with Google Maps you could disable them and create your own custom zoom controls and place them on the top of the map.
Upvotes: 1
Reputation: 181
I think this would be helpful for you. I am attempting to implement a similar layout, my solution has been to try and hide the controls on a timed interval like 3 seconds on camera updates.
I think this is the best solution without having to implement custom controls.
mapFragment.setOnCameraChangeListener(new OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition position) {
mapFragment.getUiSettings().setZoomControlsEnabled(true);
Timer t = new Timer();
TimerTask tt = new TimerTask() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mapFragment.getUiSettings().setZoomControlsEnabled(false);
}
});
}
};
t.schedule(tt, 3000);
}
});
This was mostly a proof of concept. But it does work.
Upvotes: 3