Android Touch Event Direction - android

I would like to know on how to detect on which part of the screen did the user touch it, not necessarily specific, just the direction(NORTH,SOUTH,EAST,WEST) from the middle point of the screen. Would it also affect the orientation of the screen if ever? I am using a landscape orientation.

Fetch the coordinates of the touch (getX() & getY()) and compare it to the center point of your screen. This should give you a nice hint on the 'direction' of your touch.
Hope I understood the question.
JQCorreia

Related

Android - size of the screen that is currently displayed

I am a developer in Korea.
I avail weak point very English.
Try to draw the ocean map using OpenGL ES.
Therefore, it is us with a direct manipulation of movement when you touch the screen, zoom in / zoom out function.
To get the movement value to know the difference between the width height of the screen according to the zoom state of each is likely to be.
Is there a way to check the internal coordinates of the lower right and the most coordinate of the top left of the screen to be projected in the current Android?
We can not speak English, you can complement the description of the picture.
Please help me.
Are unable to work.
I Hope this will help you:
getWindow().getWindowManager().getDefaultDisplay().getWidth();
getWindow().getWindowManager().getDefaultDisplay().getHeight();

Android rotating dialer set clickable area

I was just playing with Android SDK Demos and I found the rotating dialer example which you can find here : Android Rotating Dialer and I'm curious about one thing. How can I set the image to rotate only when I click on image..not inside in or out. I don't want to rotate it if I click at the center (in white area) or outside of the image (again in white area).
Any suggestions how can I achieve this?
Interesting question.
This would be possible by modifiying the code of myOnTouchListener. Just before the switch statement you would perform a calculation to check whether the x,y coords of the touch were outside an inner radius and inside an outer radius.
Some simple Pythagoras and it wouldn't be too hard. If this was not the case then return true at that point.

Detecting touch area on Android

Is it possible to detect every pixel being touched? More specifically, when the user touches the screen, is it possible to track all the x-y coordinates of the cluster of points touched by the user? How can I tell the difference between when users are drawing with their thumb and when they are drawing with the tip of a finger? I would like to reflect the brush difference depending on how users touch the screen, and would also like to track x-y coordinates of all the pixels being touched over time. Thanks so much in advance for any help.
This would be very tricky primarily because every android phone is going to behave differently. There are some touch screen devices that are very, very sensitive and some that are basically "dull" by comparison.
It also sounds more like you are wanting to track pressure - how hard is the user pushing on the screen - which is actually supported on android devices.
I think some of your answer may be found by monitoring all of the touch events - in practice, most applications ignore a great number of events or perform some kind of "smoothing" of the events since there is literally a deluge of touch events when the user is manipulating the screen. Doing this may negatively impact your applications performance though.
I would recommend that you look into pressure sensitivity and calculate a circular region around the primary touch point based on pressure, then build your brush around that.
Another idea would be to incorporate more of a gesture approach to what you are trying to do - for example, visualize touching the screen with the tip of two fingers together (index and middle) and rolling the middle finger around the index finger or simply moving the middle finger up and down in relation to the index finger. Both fingers would be moved together for painting. This could be used to manipulate drawing angle on the fly or perhaps even toggle between a set of pre-selected brushes or could change brush size on the fly as you are painting.
Some of the above ideas I would love to see implemented - let me know when you have your app ready.
Good luck!
Rodney
If you have a listener on your image it will respond that there was a touch within that bounding box, basically.
So, to get what you want, you could, but, I would never do this, create a box around every pixel, or small group of pixels, and listen for a touch.
Wherever you get a touch, it may fire off an event, then you can react accordingly.
I can't think of any other solution that will give you each pixel that a person touched, at one time.
You may want to read up on multitouch though, as there are some suggestions in here that my help you:
http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
If you're looking for a way to get your content view as a View after Activity#setContentView(int), then you can set an id on the outer-most element of your layout:
android:id="#+id/entire_view" and reference it in your onCreate() method after setContentView:
View view = getViewById(R.id.entire_view);
view.setOnTouchListener( ... );

In game scrolling and zooming

I'm in the process of developing an android game. I have an activity that has a custom class that extends the view and where everything is drawn. Everything works fine and I have implemented a way to draw levels and it looks good.
The problem that I have is that the levels are clearly too big for just 1 screen and re-designing them is not an option as it affects the user experience. The only solution that I see is making the screen scrollable so that you can move around the rendered stuff and zooming. What I'm looking for is double tapping anywhere to zoom in and out and scrolling to move around the map.
What I need help with is how to do this. I know how to detect that the user has scrolled or double tapped but I don't know what I should do to actually zoom in and out and scroll (if a scroll is detected).
I have been looking around and saw some very simple tutorials but all of them deal with zooming in/out of an image which is not what I need. My level is rendered using many different bitmaps so I know I need to redraw all of them when updating the screen (zoom or scroll).
Is my case the same as having a single image. When it comes to scrolling I think what need to be done is calculating how much the screen is "moved" then update the and redraw the view bitmaps with the new scaled coordinates, is this correct? What about zooming?
Any help would be much appreciated. Thanks
Zooming should be easy once you have detected where you are currently at (zoom level i.e.)
image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler);
Something like that should help you zoom out/in on the image. When the zoom levels cross a certain level, you can consider swapping out an image that is more detailed that the one you are currently rendering.

Get the touched area

I'd like to know if there's a way to get the size or the limits of a touched area ? So for instance, it could give me how many pixel the finger is covering.
In fact the same question has been posted here for the Ipad :
iPad: Measure/detect covered area by a finger touch on screen (NOT only touch coordinates)
I think it will depend also of which type of screen android is running on.
So I'd like to know if it is possible under android ? Thank you.
Try MotionEvent#getSize(int)

Categories

Resources