安卓:我可以创建一个视图/画布不是矩形的,但如回合? [英] Android: can I create a view/canvas that is not rectangular, but e.g. round?

查看:127
本文介绍了安卓:我可以创建一个视图/画布不是矩形的,但如回合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个观点,即是圆的,上面盘旋( - >在Z轴方向走出屏幕)的主要内容。当有人轻拍我想要的屏幕无论是主要内容进行选择或视图以上徘徊,当它涵盖了主视图。

I have a view that is round and hovering above (-> in z-axis direction coming out of the screen) the main content. When the someone taps the screen I want either the main content to be selected or the view hovering above, when it covers the main view.

到目前为止,这完美的作品。我有一个透明画布圆型项目。这意味着你可以看到的是,圈外的背景应有尽有。但是,你不能选择它,因为它仍然是徘徊的画布,只是用透明涂料。

So far that works perfectly. I have a round shaped item on a transparent canvas. Meaning you can see everything of the background that is outside of that circle. However, you cannot select it, because it is still the hovering canvas, just with a transparent paint.

现在我想知道,要解决这个问题,如果有可能,让视图/帆布本身的圆形?

Now I'm wondering, to solve this issue, if it is possible to make the view/canvas itself round shaped?

更新

我添加了更好的解释什么,我尽量做到图像。

I added an image for better explanation what I try to achieve.

推荐答案

据我所知 - 这是不可能的。我已经检查了<一源href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/View.java;h=30aebc9fce75cd66f5db0d98c3e78a8a1d0ec93d;hb=HEAD"相对=nofollow> View.java 的在git.kernel.org并且它基于矩形类 - rects定义的位置,大小,区域无效等。(的图的几何形状是一个矩形的。 - 从View.java评论)

As far as I know - it is impossible. I have checked the sources of View.java at git.kernel.org and it is based on Rect class - rects define position, size, regions to invalidate etc. ("The geometry of a view is that of a rectangle." - from the comments in View.java)

至于Canvas类 - 它通常是在建造或位图GL。位图绝对是rectange(矩阵),所以帆布似乎重新present一个rectange了。如果使用GL视口指定(这是一个矩形,太)。

As for Canvas class - it is usually constructed over Bitmap or GL. Bitmap is definitely a rectange (a matrix), so canvas seems to represent a rectange too. If using GL a viewport is specified (which is a rectangle, too).

这似乎是最明显的方法来检查坐标传递给你的onTouch()方法适合你的区域,并返回false,如果他们不这样做。那么事件将被传递到下方的视图,它应处理该事件。

It seems to be the most obvious way to check if the coordinates passed to your onTouch() method fit you region and return false if they don't. Then the event will be passed to the View below and it should process the event.

这篇关于安卓:我可以创建一个视图/画布不是矩形的,但如回合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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