Non-ASCII title for android map marker

2019-04-13 06:59发布

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")

2条回答
我只想做你的唯一
2楼-- · 2019-04-13 07:13

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")
查看更多
迷人小祖宗
3楼-- · 2019-04-13 07:28

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

查看更多
登录 后发表回答