开发者

Android: Is it possible to draw a view on top of the mapview as an overlay

Actually, the subject is a question.

I want to draw on top of the map a view as overlay, simply my view consist of linear layout with 9patch background and two text开发者_JAVA百科view inside. I need to draw those layouts in runtime and they will be linked to geo location

There is no problems to define such view, but it is problematic to create an overlay that will handle such draw...


Yes - this is what a FrameLayout is for! Children in a FrameLayout appear on top of each other, with the last item displayed on top and the first item displayed on the bottom.

Put your MapView as the first child of a FrameLayout and your LinearLayout as the second.


Actually there is no way to do what I want, I've found a way to convert any layout to bitmap, but firstly you need to invoke layout on the root view and define it boundaries, so in my case it is the same to simple drawing on canvas which I've used for my solution. Converting layouts to bitmap is a good thing when your layout is already drawen on the screen, but when you need to draw layout on the canvas from scratch there is no benefits due to simple drawing on canvas.


You could create a drawable out of your view by converting it to a bitmap.


Or you can try to use this. Has the same effect: https://github.com/jgilfelt/android-mapviewballoons#readme And you can modify it like you want to show whatever view you like

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜