Non-ASCII title for android map marker

♀尐吖头ヾ 提交于 2019-12-06 09:09:15

问题


I would like to be able to add a marker with a title that has only non-ASCII characters:

        marker = map.addMarker(
            new MarkerOptions()
                .title("אני")
                .position(latlng)
        );

Unfortunately the tile doesn't show up, only an empty info window. First I thought that there is a problem with the Hebrew characters in general, but they seem to be fine, because if there's ASCII text in the BEGINNING of the title, then it works:

                .title("me אני")

However it doesn't when the Hebrew is in the beginning:

                .title("אני me")

回答1:


I found a hack that seems to work, but still waiting for a real solution.

If I prepend an unicode left-to-right mark to the title, it seems to work no matter if the 1st character is rtl or ltr:

.title("\u200e" + "אני me")



回答2:


Use a customized InfoWindowAdapter, and set a layout there as you see fit.

Do note that using LinearLayout in the customized InfoWindowAdapter would cause this issue too (which is weird).

Try RelativeLayout instead, or, if you have API 17 and above, set textDirection for each of the TextViews, and it should work



来源:https://stackoverflow.com/questions/26244298/non-ascii-title-for-android-map-marker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!