java - 谷歌地图标记选项大小
问题描述
我正在尝试增加 google markerOptions 的大小,因为里面的文本并不完全可见......
这是我的代码,我没有找到设置大小的选项。
MapsInitializer.initialize(getContext());
mGoogleMap = googleMap;
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
//Normalement on va devoir boucler sur toutes les coordonnées reçu pour créer tous les markers
googleMap
.addMarker(new MarkerOptions()
.position(new LatLng(50.200323, 4.897113))
.title("Collecte de Falmagne")
.snippet("Horaires de cette collecte : \n Lundi : 10H00-15H00 \n Mardi 13H00-17H00 \n Mercredi 8H00-12H00")
);
这是一张显示我的问题的图片
提前谢谢你,抱歉英语不好!
解决方案
另一种选择是创建一个布局并将其添加到自定义 InfoWindowAdapter。
custom_info_window.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@color/blank"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/tv_title"
android:background="@color/white"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:singleLine="false"
android:textColor="@color/black"
android:textStyle="italic" />
</RelativeLayout>
在 Activity/Fragment Map 中添加自定义适配器:
private class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
@Override
public View getInfoWindow(Marker marker) {
View view = getActivity().getLayoutInflater().inflate(R.layout.custom_info_window, null);
TextView tvTitle = (TextView) view.findViewById(R.id.tv_title);
TextView tvSubTitle = (TextView) view.findViewById(R.id.tv_subtitle);
tvTitle.setText(marker.getTitle());
tvSubTitle.setText(marker.getSnippet());
return view;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
}
推荐阅读
- vuetify.js - 关闭 - 无法构建 Vuetify v2.2 并出现 sass 错误
- python - 为什么 uWSGI 不能与 boto3 一起使用?重生的 uWSGI 工作者
- android - 创建搜索界面 -Android
- c# - 如何更改此代码。因为它变成了 System.NullReferenceException
- testing - 是否需要在任何地方测试自动化机器人?
- javascript - Flash Message slideDown 不是函数
- configuration - System.Diagnostic Tracing 不适用于通过 autofac.config 添加的模块
- excel - 从 Excel 宏向单元格添加公式
- java - bean 初始化失败 SpelEvaluationException: EL1012E: 无法索引到 Spring Batch 中的空值错误
- php - PHP进程吃掉所有内存