删除或移动Android Studio for Mapbox上的“重置北”按钮

问题描述 投票:1回答:1

我想知道是否有办法移动Mapbox生成的“重置北”按钮的位置。它位于我的EditText(搜索)屏幕的右上角,因此我的EditText会阻止它。其他选项是添加自定义“重置北”按钮,但我仍然需要移动或删除原始功能。

我累了mapboxMap.getUiSettings().setCompassMargins(left, top, right, bottom);

但应用程序崩溃错误:

'on a null object reference'

链接到上一个问题,没有人回复。 Old Question

android mapbox
1个回答
0
投票

我有同样的错误,直到我意识到我将填充或罗盘边距放在我的onCreate(Bundle)而不是我的onMapReady(@NonNull MapboxMap)。

因此,在onMapReady(@NonNull MapboxMap)中,您可以将以下代码放在方法的末尾:

MainActivity.this.mapboxMap.getUiSettings().setCompassMargins(left, top, right, bottom);

或者,如果要在MapboxMap中的所有组件周围设置填充,则可以使用此方法:

MainActivity.this.mapboxMap.setPadding(left, top, right, bottom);
© www.soinside.com 2019 - 2024. All rights reserved.