Android:是否可以在地图视图之上绘制一个视图作为叠加层
其实这个题目是一个疑问句。
我想在地图顶部绘制一个视图作为叠加层,简单地说,我的视图由带有 9patch 背景的线性布局和内部两个文本视图组成。我需要在运行时绘制这些布局,它们将链接到地理位置
定义此类视图没有问题,但创建一个处理此类绘制的覆盖层是有问题的...
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 textview 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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的 - 这就是
FrameLayout
的用途!FrameLayout
中的子项显示在彼此的顶部,最后一个项目显示在顶部,第一个项目显示在底部。将 MapView 作为 FrameLayout 的第一个子级,将 LinearLayout 作为第二个子级。
Yes - this is what a
FrameLayout
is for! Children in aFrameLayout
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.
或者你可以尝试使用这个。具有相同的效果: https://github.com/jgilfelt/android-mapviewballoons#readme
你可以修改它,就像你想显示你喜欢的任何视图一样
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