Remove or move 'Reset North' button on Android studio for Mapbox

时光毁灭记忆、已成空白 提交于 2019-12-13 18:49:02

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!