dze*_*kei 27 android google-maps android-mapview
我的每个底角都有两个按钮MapView
,部分遮挡了左下角的Google徽标.
为了符合API的条款和条件,我需要将Google徽标重新定位到更加明显的位置.即在按钮上方.
谷歌API文档声明谷歌徽标是在onDraw()
方法中绘制的,MapView
但我不知道如何正确覆盖它,因为谷歌地图是封闭源.
我能做到这一点在iPhone通过找到正确UIView
的MKMapView's
孩子,但我想不通,我怎么能在Android中做到这一点.
dze*_*kei 34
Google Maps SDK v2 for Android添加了此功能.
用于GoogleMap.setPadding()
向"活动"区域添加填充(包括Google徽标和版权声明),同时仍填充整个容器.
https://developers.google.com/maps/documentation/android/map#map_padding
Jkn*_*air 13
您可以借助分配给它的标记移动Google徽标GoogleWatermark
.在下面的代码中,我将其移动到屏幕的右上角.
View googleLogo = binding.missionMap.findViewWithTag("GoogleWatermark");
RelativeLayout.LayoutParams glLayoutParams = (RelativeLayout.LayoutParams)googleLogo.getLayoutParams();
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_START, 0);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_END, RelativeLayout.TRUE);
googleLogo.setLayoutParams(glLayoutParams);
Run Code Online (Sandbox Code Playgroud)
在哪里添加missionMap
了framelayout MapFragment
.
我遇到了同样的问题,但你可以实现你想要的,而不会与谷歌的条款和条件相冲突.主要是将mapView放在Frame布局中,例如:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout android:id="@+id/map_frame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.7" >
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="mySecretMapsApiKey"/>
</FrameLayout>
<ws.mentis.android.guardian.ui.MapNavBar
android:id="@+id/map_nav"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:layout_gravity="bottom"
android:layout_weight="0.3" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我有很多按钮,所以我在自定义小部件(MapNavBar)中创建了它们.正如您在屏幕截图中看到的那样,Google徽标仍然可以在新窗口中显示在正常位置.
这适用于Android 2.2它还具有标准变焦控制也向上移动的优点,因此它不会干扰您自己的按钮.
归档时间: |
|
查看次数: |
15926 次 |
最近记录: |