简体   繁体   English

如何将图像(标记)放置在圆圈内并使它们可单击/可触摸?

[英]How to place Images(markers) inside a circle and make them clickable/touchable?

What I want to do: 我想做的事:

It should be something like a radar. 它应该像雷达。 I send my geocoords to an API and get "people" back, and also their distance to me. 我将我的地理坐标发送给API,然后找回“人们”以及他们与我的距离。

I have a round image as background, my radar screen, and I want to place a marker(another Image) on that image for every person I got back from the API. 我有一个圆形的图像作为背景,雷达屏幕,并且我想为从API返回的每个人在该图像上放置一个标记(另一个图像)。 In the center is my position and depending on the distance and direction, that marker should be placed. 我的位置在中间,并应根据距离和方向放置该标记。

While the radar is a circle I can´t work with normal coordinates(they would be a rectangle). 虽然雷达是圆形的,但我无法使用法线坐标(它们将是矩形)。 So my first question is, can you give me a pest practice or any advice how to do this? 因此,我的第一个问题是,您能给我一个有害生物的实践方法或任何建议吗? Placing Bitmaps over Bitmaps? 将位图放置在位图上? But How to place them inside that circle? 但是如何将它们放置在该圆圈内?

On top of that, i want that markers to be clicked/touchable. 最重要的是,我希望标记可以被点击/触摸。 If two or more markers are really near togehter, so that you cant touch/click them seperatly, I need a way to find out, which markers are clicked/touched. 如果两个或两个以上的标记确实很接近,以至于您无法分别触摸/单击它们,那么我需要一种方法来找出单击/触摸了哪些标记。 Or maybe in other words, which markers are placed inside the touched/clicked area. 或者换句话说,哪些标记位于触摸/单击区域内。

How should I implement this? 我应该如何实施呢?

Maybe android offers something I don´t think of (hopefully). 也许android提供了一些我没想到的东西(希望如此)。

Thanks in advance!!! 提前致谢!!!

I would create a custom view that fits your your case... for example: 我将创建一个适合您情况的自定义视图,例如:

public class RadarView extends View {
    @Override
    protected void onDraw(Canvas canvas) {
        // draw the background
        // draw each dots.
    }
}

Of course the view will have to have a list of all the dots to press, as well as their positions. 当然,视图将必须具有要按下的所有点及其位置的列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM