如何放置针标记图像在android系统中的图像? [英] How to place pin mark image over an image in android?

查看:148
本文介绍了如何放置针标记图像在android系统中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid。我正在开发一个项目,我会得到的无线电信号值(我可以从API获取值)。我有一个平面图。平面图有厨房,大厅,卧室的部分。如果我点击厨卫节,我需要放置一个引脚形象在这一节中与无线电信号的值。当我点击保存,我需要锁定的图像(值)的特定部分。同样地,我可以把许多基础上,要求针脚图像。

I am new to Android. I am developing a project where I will get the Radio signal values(I can get the values from API). I have a floor plan. The floor plan has kitchen,hall,bedroom sections.. If I click the Kitchen section, I need to place an Pin Image in that section with Radio signal values. Once I click Save, I need to lock the Image(with values) in that particular section. Similarly I can place many Pin images based on the requirement.

请给我一些相关的链接或样品codeS开发这个。我重视的图片,供大家参考。任何帮助将是非常美联社preciated。

Please give me some related link or sample codes to develop this. I have attached the Image for your reference. Any help would be really appreciated.

推荐答案

要做到这一点的方法之一是使用画布。

One way to do this would be to use canvas.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.map);
    canvas.drawBitmap(map, xPositionForMap, yPositionForMap, null);

    Bitmap marker = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
    canvas.drawBitmap(marker, xPositionFor1stMarker, yPositionFor1stMarker, null);
    canvas.drawBitmap(marker, xPositionFor2ndMarker, yPositionFor2ndMarker, null);
}

后来在OnDraw中绘制的东西出现在这些早期绘制的顶部。也许BitmapFactory.de codeResource应该在创建/初始化垫HOD所以他们不叫每次OnDraw中被调用时。请参见 http://developer.android.com/training/custom-views/定制drawing.html 了解详情。

有关点击引脚,你会赶上包含画布上的布局点击和有条件地添加额外的可绘制和文字。

For clicking on the pins you would catch clicks on the Layout containing the canvas and conditionally add extra drawables and text.

这是另一种方法是使用RelativeLayout的放ImageView的,这将与此类似。

An alternative way is to use RelativeLayout and put ImageView, which would work similarly.

这篇关于如何放置针标记图像在android系统中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆