对齐在谷歌地图标记片段的文字 [英] Aligning the text in Google Maps Marker snippet
本文介绍了对齐在谷歌地图标记片段的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想串在我的代码片段对齐到中心。
I want the string in my snippet to be aligned to the center.
此外,线路断路器(\ n)以片段转换为空格,有没有办法来插线断路器?
Also, line breakers (\n) in the snippet are converted to spaces, is there a way to insert line breakers?
我的有关code:
GoogleMap map = ...
map.addMarker(new MarkerOptions().position(pos)
.title("title")
.snippet("body \n and mind");
感谢
推荐答案
使用一些实例中,以及从答案:<一href="http://stackoverflow.com/questions/15090148/custom-info-window-adapter-with-custom-data-in-map-v2">custom信息窗口适配器在地图V2 自定义的数据,我遇到了以下解决方案:
Using some examples, as well as answers from: custom info window adapter with custom data in map v2, I've come across the following solution:
marker.xml
marker.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的:
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;
}
});
这篇关于对齐在谷歌地图标记片段的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文