How to move the Android Google Maps API Compass Position

前端 未结 7 1581
太阳男子
太阳男子 2020-12-05 13:57

Does anyone know if you can change the compass position within the map?

All I can find is how to enable or disable it. But I need to move it down a bit so my overlay

7条回答
  •  无人及你
    2020-12-05 14:46

    On 2.0 map api.

            // change compass position 
        if (mapView != null &&
                mapView.findViewById(Integer.parseInt("1")) != null) {
            // Get the view
            View locationCompass = ((View) mapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("5"));
            // and next place it, on bottom right (as Google Maps app)
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)
                    locationCompass.getLayoutParams();
            // position on right bottom
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
            layoutParams.setMargins(0, 160,30, 0); // 160 la truc y , 30 la  truc x
        }
    

提交回复
热议问题