我希望片段中的字符串与中心对齐。
另外,代码片段中的换行符(\n)被转换为空格,有没有办法插入换行符?
我的相关代码:
GoogleMap map = ...
map.addMarker(new MarkerOptions().position(pos)
.title("title")
.snippet("body \n and mind");
Thanks
使用一些示例以及以下答案:带有地图 v2 中的自定义数据的自定义信息窗口适配器 https://stackoverflow.com/questions/15090148/custom-info-window-adapter-with-custom-data-in-map-v2,我遇到了以下解决方案:
标记.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" />
</RelativeLayout>
Java:
map.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(R.layout.marker, null);
TextView info= (TextView) v.findViewById(R.id.info);
info.setText(marker.getPosition().toString());
return v;
}
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)