问题
I was wondering if there was a way to move the location of the 'Reset North' button that is generated by Mapbox. It is in the top right of the screen where my EditText (search) is, so my EditText blocks it. Other option is adding a custom "Reset North" button, but I would still need to move or remove the original function.
I have tired mapboxMap.getUiSettings().setCompassMargins(left, top, right, bottom);
but the app crashes Error:
'on a null object reference'
Link to previous question, no one is replying to that. Old Question
回答1:
I had the same error until I realized that I was putting the padding or compass margins in my onCreate(Bundle) and not my onMapReady(@NonNull MapboxMap).
Therefore in your onMapReady(@NonNull MapboxMap) you can put the following code at the end of the method:
MainActivity.this.mapboxMap.getUiSettings().setCompassMargins(left, top, right, bottom);
Alternatively you can use this, if you want to set the padding around all components in the MapboxMap:
MainActivity.this.mapboxMap.setPadding(left, top, right, bottom);
来源:https://stackoverflow.com/questions/53032179/remove-or-move-reset-north-button-on-android-studio-for-mapbox