Android : Know MotionEvent Is Relative / Absolute?

Sep 11, 2009

I am implementing OnTouchListener and am receiving MotionEvent objects. Some ACTION_MOVE events reports absolute X/Y coordinates, while some reports relative coordinates.

How can I ask a MotionEvent what kind of coordinates it currently represents?

Android : Know MotionEvent is relative / absolute?


MotionEvent And Relative Layout?

Nov 24, 2011

I have a relative layout built from XML.I am capturing the onTouchEvent.When I touch the screen anywhere except over the TableLayout or ImageButton

the MotionEvent.ACTION_DOWN and MotionEvent.ACTION_MOVE

events work fine.

how to make the onTouchEvent() work on the TableLayout and ImageButton views?

The purpose of the exercise was to have a drag method working over the relative layout,no

Maybe manipulating the layout_margin values? I was contemplating a transparent canvas overlay but haven't figured that out yet.

Code snippets below

XML
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"[code]......

View 2 Replies View Related

Android :: How To Get Absolute Time?

Aug 20, 2010

I'll notify something to user after 30 minutes for example. so I need to get a time which is not changable by user or anything. Does it call UTC? I guess I need to get current time and it should have nothing to do with user handle or location actually, I'm focusing '30minutes from now' rather than current time. It also should work even in case of power off and on. Can I use alarm manager for this?

View 12 Replies View Related

Android :: Does MotionEvent.getEdgeFlags() Ever Return Anything Other Than 0

Nov 14, 2009

I was expecting the getEdgeFlags() method of MotionEvent to tell me when a MotionEvent had reached the edge of something, but the value returned from getEdgeFlags() is *always* zero. Is this the expected behavior? The documentation says that the flags indicate when a touch has reached the edge of the display. I've tried this on a real device and in the emulator, and the location coordinates never quite reach the edge of the display, and getEdgeFlags() always returns 0. By "never quite reach" I mean that if dragging a finger off the left edge of the display, the smallest X I got was 2. Reaching the edge of the view doesn't seem to change the value returned either.

I suppose I could set the flags myself using setEdgeFlags() using calculations with known dimensions of the object whose edges I care about. Is that how it's supposed to be used? Is this broken for now?

View 3 Replies View Related

Android :: GetPressure Vs GetSize For MotionEvent

Sep 10, 2009

Debugging on my G1 phone, I am trying to use android.view.MotionEvent.getPressure() and MotionEvent.getSize().

For MotionEvent.getSize(), I always get 0 (the documentation says it returns a value ranging from 0 to 1;

For MotionEvent.getPressure(), it seems to me this actually reflects the real finger touch size, as opposed to "pressure"; for me, I get values range from 0 - 0.63.

Am I missing anything or is it a known bug of the SDK?

View 4 Replies View Related

Android :: Motionevent.getX And GetY

Sep 3, 2010

I have a display that is 854x480 pixels. Why is it that the MotionEvent.getX and getY methods return floats? As far as I can tell, the pixels on the display are discrete integers, there is no such thing as a half a pixel on the display.

View 1 Replies View Related

Android : Get Absolute Coordinates Of A View?

Feb 8, 2010

I'm trying to get the absolute screen pixel coordinates of the top left corner of a view. However, all methods I can find such as getLeft() and getRight() don't work as they all seem to be relative to the parent of the view, thus giving me 0. What is the proper way to do this?

If it helps, this is for a 'put the picture back in order' game. I want the user to be able to draw a box to select multiple pieces. My assumption is that the easiest way to do that is to getRawX() and getRawY() from the MotionEvent and then compare those values against the top left corner of the layout holding the pieces. Knowing the size of the pieces, I can then determine how many pieces have been selected. I realise I can use getX() and getY() on the MotionEvent, but as that returns a relative position that makes determining which pieces were selected more difficult. (Not impossible, I know, but it seems unnecessarily complicated).

View 4 Replies View Related

Android : Can I Get Absolute Screen Position?

Nov 4, 2009

View.getLeft() and View.getTop() give the position of the view relative to the parent.

Is there a way to get the absolute screen position of that view?

Either a way to translate those coordinates into screen coordinates to make a call to get the position in screen coordinates.

View 2 Replies View Related

Android : Absolute Best Droid Performance?

Oct 29, 2010

I am trying to go widget-free, using Zeam launcher instead of LauncherPro which seems to randomly have issues for me, I'm just wondering what tips you all may have for getting the best performance possible from your phone. I'm on a Captivate. I care more about in-app performance and stability over bells and whistles. What do you suggest?

View 6 Replies View Related

Android :: Get Absolute File Path From URI Instance

Sep 2, 2009

I need to get the absolute path of the file associated with a specific android.net.Uri instance. I know how to get the URI instance based on the file instance (with Uri.fromFile(file)) and i need the inverse action.

View 4 Replies View Related

Android :: What Is Absolute Path Of Assets Folder?

Nov 9, 2010

What is the absolute path of the assets folder? I need it to reference some images saved in this folder from a html file saved in the memory device.

View 1 Replies View Related

Android :: Absolute Path Of Assets Folder

Nov 11, 2010

How do I reference the assets from phone memory? I need it to write the absolute path into a html file to load some images which are in assets folderThis html is saved in the phone memory but I can't to save these images in the memory phone because these are very big.

View 1 Replies View Related

Android :: Activity To Generate MotionEvent.ACTION_UP

Apr 9, 2010

I am having trouble getting my activity to generate a MotionEvent.ACTION_UP. Probably a beginner's error.

In LogCat, I'm only seeing the ACTION_MOVE event (which is an int value of 3). I also see the X/Y coordinates. No ACTION_DOWN and no ACTION_UP.

I looked everywhere for a solution. I found one question on a forum that seems to be the same as my issue, but no solution is proposed: http://groups.google.com/group/android-developers/browse_thread/thread/9a9c23e40f02c134/bf12b89561f204ad?lnk=gst&q=ACTION_UP#bf12b89561f204ad

Here's my code:

CODE:..........................

View 1 Replies View Related

Android :: Strategies For Using Touchscreen MotionEvent Coordinates

Mar 17, 2010

I'm writing a simple tile based game using a canvas and a 5X5 grid of tiles. To determine if a tile is clicked I look at the MotionEvent supplied by onTouch. I get the coordinates when MotionEvent.event is ACTION_UP and translate to tiles. This works great on the emulator but when I touch on a device the actual coordinates of the touch register higher than I'd expect as a end user.

I'm wondering what strategies people have used to get a closer to "expected" result. Do you use a simple Y offset? Do you average the coordinates over the life of the touch? Do you use other methods?

View 4 Replies View Related

Android :: MotionEvent - Left - Right And Click Event In My App

Jul 10, 2009

I need to have a left, right and click event in my App.

I am trying it like below:

CODE:...........................

View 2 Replies View Related

Android :: MotionEvent HistorySize And Multiple Pointers

Aug 22, 2010

I couldn't find a definite reference for the size of a MotionEvents history, when there are multiple pointers. The reference says that if you use a getHistorical* function, you might pass it a history position which is somewhere between [0..getHistorySize()-1]. But in a lot of examples handling multitouch if there are multiple pointers they only use history positions between [0..getHistorySize()/ getPointers()-1] (so they divide the history's size with the number of pointers). Which one is the correct way?

View 8 Replies View Related

Android :: MotionEvent: Event.getHistoricalEventTime(int Pos) Broken?

Oct 22, 2010

It seems like making any call to event.getHistoricalEventTime(int pos) when there is historical touch position data available makes my application crash. I've searched online and it seems like no one ever uses this method.

View 4 Replies View Related

Android :: Metric Of MotionEvent API GetPressure - GetSize

Oct 12, 2010

I'm working on a program which used the functions as title.

There's a problem that the tunctions above do not have their metrics on API website.

To avoid misunderstanding, here is an example about "metric" I metioned before.

Ex. size = pixel, pressure = kilogram(kg)

I have no idea about the metric at all.

View 1 Replies View Related

Android :: Properly Pass MotionEvent To A Worker Thread?

Jul 20, 2009

My app forwards MotionEvents, reported by GestureDetector.OnGestureListener, to a worker thread. Right now i am doing it by calling MotionEvent.obtain, pass the obtained copy to the worker thread, handle it and recycle it at the worker thread. Is it required to obtain and recycle a MotionEvent if it is passed to another thread? Or could it safely be skiped? If i am making things overly complicated, could you please explain me at which conditions MotionEvent.obtain is usually called?

View 2 Replies View Related

Android :: MotionEvent - Cant Find Left And Right Motion Event

Jul 1, 2010

I am developing one application in which there is an imageview...in which i want to move left or right using mouse touch...for that i found "android.view.MotionEvent" but in MotionEvent there are few events among that ACTION_CANCEL 2. ACTION_DOWN 3. ACTION_UP ......etc.

Hence there is no such event for "LEFT" and "RIGHT" action....so is there any other way to implement the "LEFT" and "RIGHT" move ?

View 1 Replies View Related

Android :: MotionEvent - How To Get Coordinates Of Touch/ Pointer/mouse

Sep 26, 2010

I'm trying to get coordinates of the mouse, but there seems to be no easy ways. Can't make the MotionEvent object because the constructor is private. Can anyone please tell me how to get the coordinates of the touch/ pointer/mouse? I only want the touch coordinates of ImageView, but wouldn't mind the touch coordinates anywhere on the screen.

View 2 Replies View Related

Android : Setup Absolute Position Of A View In Droid?

Jul 20, 2010

Is it possible to set the absolute position of a view in android? (I know that there is an AbsoluteLayout, but it's deprecated...)
Lets say I have a screen 240x320px, and I want to put an ImageView which is 20x20px with its center at the position (100,100).
What do I have to do?

View 1 Replies View Related

Android : Change Absolute Position Of A View Programmatically?

Aug 9, 2010

If you use an AbsoluteLayout (I know that it is deprecated, but it was the only way to solve my problem ) you can give the childViews the tag "android:layout_x" and "android:layout_y" to set their absolute position within the AbsoluteLayout.

However I dont want to set these informationen in the xml, because I only know them at runtime. So how can I set these parameters at runtime programmatically? I dont see any method on the View like view.setLayoutX(int x) or something.

Here is my XML, which works fine, when I set the layout_x and layout_y values. code...

View 1 Replies View Related

Android : Setup Images Position In Absolute Layout?

Nov 21, 2010

I have an image setup inside an absolute panel.I am trying to set it's position via code.But I do not see any applicable method/property to set its position.

Here is my layout.

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>

<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/marker" android:src="@drawable/marker" android:layout_y="106dp" android:layout_x="290dp"></ImageView>
</AbsoluteLayout>

Here is my code to set its position...

View 1 Replies View Related

Android : Way To Get Absolute Path And Filename From VideoView Object

Jan 10, 2010

Just started writing java / android and I am trying to use android.widget.VideoView.

I set the video by using the setVideoPath('/path/filename') method, but can't seem to figure out how to get the path on an existing object?

I'm using methods such as 'getDuration()', and 'getCurrentPosition()' and they work great.. but where is a getPath method?

View 1 Replies View Related

Android : Retrieve Video Thumbnail From An Absolute Path?

Mar 31, 2010

I know this has to be trivial but I just don't find the right resource, I guess.
So all I want to do is retrieving a thumbnail for a video. All I have is the absolute path to the file on the sdcard as a String. So please point me into the right direction.

View 1 Replies View Related

Android : Want To Set Full Image In Absolute Layout In Droid?

Jul 28, 2010

I have set image in AbsoluteLayout but it'll not display in full screen on G1 but when i run the same application in Nexus it is working properly.

I have set setContentView(new Test(this)) in my activity class. Test is my AbsoluteLayout class.

My code looks like...

Can anyone tell me that why i am not getting full image on G1 mobile screen?

View 1 Replies View Related

Android :: 2.1 - MotionEvent Multiple Touch Events Get Mixed Up And Influence Each Other

Sep 24, 2010

Purpose of the app:

A simple app that draws a circle for every touch recognised on the screen and follows the touch events. On a 'high pressure reading' getPressure (int pointerIndex) the colour of the circle will change and the radius will increase. Additionally the touch ID with getPointerId (int pointerIndex), x- and y-coordinates and pressure are shown next to the finger touch.

Following a code snipplet of the important part (please forgive me it is not the nicest code ;) I know)

CODE:.............

The problem:

A HTC Desire running Android 2.1 is the test platform. The app works fine and tracks two finger without a problem. But it seems that the two touch points interfere with each other when they get t0o close -- it looks like they circles 'snap'to a shared x and y axle. Sometimes they even swap the input coordinates of the other touch event. Another problem is that even though getPressure (int pointerIndex) refers to an PointerID both touch event have the same pressure reading.

As this is all a bit abstract, find a video here: http://www.youtube.com/watch?v=bFxjFexrclU

My question:

Is my code just simply wrong? Does Android 2.1 not handle the touch events well enough get things mixed up?Is this a hardware problem and has nothing to do with 1) and 2)?

View 1 Replies View Related

Android :: Motionevent - Multitouch Events Give Wrong Coordinates

Jan 6, 2010

I have been racking my brain to try to figure out what is going wrong here. I wanted to experiment with multi-touch, so I decided to add the controls for LunarLander to the touchscreen.

Instead of adding buttons, I defined regions on the screen that when touched, would act like the buttons on the keyboard (for example, the gas fires as long as you press the screen in the area defined for the gas button, and stops firing when you release.)

To do this, I added the onTouchEvent override to the LunarView class as follows:

CODE:.....................

View 2 Replies View Related

Android :: Is Bad MotionEvent/Touch Slowdown Stuff Actually Fixed On First-gen 2.1 Updates

Apr 18, 2010

I'd really like to know what the state of that fix is as 2.1 is rolled out onto first generation (MSM7200-based) devices. As it stands, I don't see much of a problem with touch eating up CPU on the Droid and N1 but those are much faster phones so I don't think it would be quite as pronounced on them. My current 1.6 devices (G1 and Tattoo) cut my framerates in half during any touch (with the sleep hack, even). I optimized my new games so that they would run well-enough (25-40fps) on that hardware but they have very touch-centric interfaces so won't work well with that bug. I talked to a few people who run 2.0/2.1 mods on their G1s and they said the problem isn't any better. They still see the big slowdown. I tested on my 1.6 emulator vs a 2.1 emulator and there is a huge improvement. The 1.6 emulator slows down just like my G1 does and the 2.1 emulator shows only a tiny bit of slowdown, which is what I was hoping for. That's encouraging, but I have yet to see a real 2.1 MSM7200 update in the field so I don't know what to think yet.

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved