views:

82

answers:

2

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?


Update

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

A: 

You need to specify an Android Selector to avoid the default hovering image.

Macarse
Maybe I didn't explain myself correctly, but I added an image to clarify. I don't think that Selector is the solution to that, but if I'm wrong please let me know.
znq
Can you explain what is that circle? it's an image it should be shown always? it should have a selector? I can access it using the dpad?
Macarse
The circle is some kind of a "pop-up" hovering above the main layer. It's on the z-axis going out of the screen above the main content view.You can see it like an AlertDialog, but round instead of rectangular and the possibility to select items from the background.
znq
@Stefan Klumpp: It should work with a selector, can you paste some code to reproduce the issue?
Macarse
@Macarse: Maybe you're right. Could it be that the link in your answer is wrong and you tried to point me to that one instead? http://developer.android.com/reference/java/nio/channels/Selector.htmlThat's why I was confused and thought what you meant with Selector is not correct.
znq
Actually after looking at both links again I still don't get how to use a Selector in there. Will prepare some code and add it to my question shortly.
znq
+1  A: 

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)

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).

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.

zserge
Thanks zserge for the detailed answer. The last point mentioned is exactly what I'm doing now, but I have some other issues with that, which I have described here: http://stackoverflow.com/questions/3832893/android-delegate-touch-event-to-underlaying-view
znq