Home > Net >  How to move position of ZoomControls in google map android?
How to move position of ZoomControls in google map android?

Time:09-20

I'm implementing google maps in my Android app, I have managed to implement google map up and running. Now the problem is current design of the application that I'm getting overlap of the zoom control in google map. How do I move this zoom control to another position? Thanks

CodePudding user response:

you can try this code

   mMap.getUiSettings().setZoomControlsEnabled(true); //enable the zoomcontrol
    int ZoomControl_id = 0x1; //id of zoomcontrol
    int MyLocation_button_id = 0x2;

    // Find ZoomControl view
    View zoomControls = mapFragment.getView().findViewById(ZoomControl_id);

    if (zoomControls != null && zoomControls.getLayoutParams() instanceof 
   RelativeLayout.LayoutParams) {
        // ZoomControl is inside of RelativeLayout
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) zoomControls.getLayoutParams();

        // Align it to - parent top|left
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

        // Update margins, set to 15dp
        final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 150, getResources().getDisplayMetrics());
        params.setMargins(margin, margin, margin, margin);
    }
  • Related