Draw over app and just manage scrolling events in Android - android

I'm trying to draw view over other apps with transparent theme filling width and height.
I need to pass my touch events to the app that i draw on. But there is a restriction -- only scrolling (up and down) has to pass to app, NOT clicks , double taps etc.
When user clicks something, there shouldnt be any action on the app that i draw on.
But, user can scroll up & down in the app so he can view what's going on.
How can i achieve this?

Related

How to implement double tap on home screen? (Not in the app screen)

I'm making an app of auto-changing wallpaper.
Now, I want to add a function that changes wallpaper by double tapping the home screen.
I did some searches, but only found information about implementing double tap on app screen, not device's home screen.
Can someone tell me how to get listener of double tap event on device's home screen? Or at least how to get listener of just tap on device's home screen?
Your wallpaper is your app screen, you can handle touch events on its SurfaceView like you do with any View. Here's an answer about it:
How to implement double tap for surface view in android
Just bear in mind that if you're using a GlSurfaceView it runs on its own thread, so you need to handle events like this. And the launcher app sits on top of your wallpaper, so you can only handle touch events it allows through.

How can I stop input from registering inside my game when I am dragging status bar from the top?

Basically on newer phones such as the ones with the notch at the top I have been able to play games where I swipe the top of my screen to access the status bar without any input impacting my game.
Games such as Circle and Jelly Jump) are examples that do this.
I basically want a similar sort of thing. Right now when I drag down my status bar from the top, my game ends up activating which is something I don't want.
My code to start the game is upon a very simple mouse down input which also registers as a touch on phones:
if (Input.GetMouseButtonDown(0))
{
Jump();
}
An example of what I want can be shown via this diagram I've
drawn here.
You could have an invisible UI panel in that area and then check using EventSystem.current.IsPointerOverGameObject() to check if the click/touch is over an UI element. Not that for touch, the function is IsPointerOverGameObject(touchID). Also you will need a graphic raycaster attached to the canvas.
Another option would be to check the x/y value (depending on orientation) of the touch position and to only register input if it's above a certain value.
if(Input.GetTouch(0).position.x < 20) return

How to use gesture on specific place of screen in android

I am wondering how to check if the user is performing gesture on our predefined area. I have an criteria and that is , let suppose , If I have a transparent graphics of word "B" on the screen , then user should start filling it with color with gesture (with the touch of his finger). he starts it with the below corner of the B and end up how we write the b when writing with the pencil.
So how to achieve this type of gesture and how to just restrict user to use the gesture on on that part of the screen ? please any idea about it or share me any thing which is similar to it.

Android: detecting presses inside grid

I am making a game of Gomoku in Android. I have made a grid out with drawLine(): http://i.stack.imgur.com/Mm4HZ.jpg
I am now trying to make the app detect presses within the small squares. I was thinking perhaps I could generate buttons to be in the center of each square. I have the height/width of a single square saved to varibles so getting the center points to each square shoudln't be difficult. However, how should I dynamically generate buttons where each corresponds to a certain [i][j] in a 10 * 10 matrix where the field data is stored?
You can register an onClickEvent with any view in android. What you want is an invisible view the area of the places were you want click events. I suggest using buttons or something visual so that you can see where the areas are, register the click events for each view, then hide the views so that they are invisible.

have textview change style/attribute on touch roll-off

Ok, I simply can't figure this out for the life of me. I created a custom textview and I basically want it to be a button. I have all my code working except that I can't get it to detect when touched, and then the touch event rolls out of its boundary. Say the textview lights up grey when touched, then if the user drags their finger away to the left or right, I want to have the grey disappear and reset to its normal background color.
I realize I can just use the standard android button, but I don't like how it delays on changing color for the touch event. Maybe someone knows where the stock Button.java class code is, for the android API so I can look at that for hints?
I have tried getting the dimensions of the button with an on global listener and then tracking user touch events to be within those dimensions. And the dimensions and touch location are reported correctly and works sometimes, but it simply doesn't work reliably, maybe due to the user moving too quickly, for example. Even if I set the touch boundary a few pixels inside of the actual boundary.

Categories

Resources