motionevent

PointerIndex versus id in android

自闭症网瘾萝莉.ら 提交于 2020-07-06 13:29:28
问题 I m referring to some websites like http://developer.android.com/reference/android/view/MotionEvent.html http://www.vogella.com/tutorials/AndroidTouch/article.html to learn MotionEvent for designing User Interface. The problem is i am getting confused with terminologies like pointerIndex,Id ,getActionIndex, getActionMasked and other important methods related to MotionEvent. 回答1: Motion events describe movements in terms of an action code and a set of axis values.The action code specifies the

Android - Detect Touch Pressure on capacitive touch screen?

安稳与你 提交于 2020-04-10 03:34:33
问题 I've heard of: MotionEvent e; float press = e.getPressure(...); But this only returns 0 for no touch, and 1 when my finger touches the screen. Is it possible to find a value for the amount of pressure your finger is putting on the screen with touch capacitive screens? Or is my hunch correct that this will only work with resistive screens..? 回答1: MotionEvent().getPressure(i) should return a value between 0 and 1 based on the "pressure" placed on the screen. In reality for capacitive screens it

Android - Use SYSTEM_OVERLAY to change touch events

China☆狼群 提交于 2020-01-16 04:37:11
问题 My question is pretty much similar to this one. The question was asked almost 3 years ago and was not answered yet. My goal is to catch all touch-events using a system-overlay (see code below), change the event's parameters (i.e. event.x = event.getX()+5) and pass it on to the current running application (any application). Currently, I can catch all MotionEvent's by using the TYPE_PHONE flag OR pass all of the events to to the current application by using the TYPE_SYSTEM_OVERLAY, but not both

Android : Get view only on which touch was released

别等时光非礼了梦想. 提交于 2020-01-10 04:26:04
问题 I am in a tricky situation, hope you can help me with it. I have few views (TextViews), horizontally placed one after another in a linear layout. When I press on textview1, drag my finger to any other textview and release touch, I want to be able to get the view(textview) on which the finger was lifted. I went over the TouchListener api, it says that every event starts with a ACTION_DOWN event action. Since other textviews won't fire that event, how can I get the reference to the textViews on

Inner Recyclerview not receiving click event

三世轮回 提交于 2020-01-01 17:26:30
问题 I have a parent recyclerview with filled with cards and an inner recyclerview inside each card. The scrolling for the inner recyclerview inside the cards has been disabled but this has also affected the inner recyclerview's ability to receive click events. To disable the scrolling, I had followed a very similar approached to Lucas Crawford's answer here which suggested that you create a custom recyclerview class and override dispatchTouchEvent: Disable Scrolling in child Recyclerview android

getPressure always returning 1.0

喜欢而已 提交于 2019-12-31 04:46:07
问题 Does anyone have any idea why getPressure() returns always 1.0 ? Here is my code: @Override public boolean onTouchEvent(MotionEvent event) { super.onTouchEvent(event); System.out.println(event.getPressure()); return true; } 回答1: Does anyone have any idea why getPressure() returns always 1.0? The typical touchscreen / input device has no way to measure pressure. You either don't press and get no touch event or you press and get a touch event with value 1. 回答2: https://groups.google.com/forum/#

onInterceptTouchEvent, onTouchEvent only see ACTION_DOWN

北城余情 提交于 2019-12-30 18:36:37
问题 I have a top level ViewGroup, which I call SliderView, in which I want to detect swiping. This is mostly working, but one weird failure persists. The essence of SliderView is to override onInterceptTouchEvent and, once the user is actually swiping, return "true" to prevent other views from seing the MotionEvent. Here is a snip of code: public class SliderView extends ViewGroup { enum MoveState { MS_NONE, MS_HSCROLL, MS_VSCROLL }; private MoveState moveState = MoveState.MS_NONE; ... other code

WebView getting rid of double tap zoom.

社会主义新天地 提交于 2019-12-29 07:38:07
问题 I read many tickets on the topic of Zooming in WebViews and didnt came to an answer for my case. Here´s my setup: I´m using a custom webview with generally these settings: getSettings().setBuiltInZoomControls(false); getSettings().setSupportZoom(false); getSettings().setUseWideViewPort(true); getSettings().setLoadWithOverviewMode(true); Let me note right here that i depend on OverviewMode and as well on WideViewPort to Scale my WebView. I´m also Overriding my OnTouchEvent and and delegate all

Convert RGB to X and Y in a bitmap

三世轮回 提交于 2019-12-25 16:56:32
问题 I have a code which takes a bitmap and converts the X and Y coordinate to RGB: int pixel = bitmap.getPixel((int)x,(int) y); inRed = Color.red(pixel); inBlue = Color.blue(pixel); inGreen = Color.green(pixel); How do I convert a given RGB and get the X and Y coordinate within the bitmap? 回答1: To find the first pixel in a Bitmap with given Color: int color = // your color int x, y; // used for output boolean found = false; for (int ix = 0; ix < bitmap.getWidth(); ++ix) { for (int iy = 0; iy <

How to detect a MotionEvent inside dispatchTouchEvent

时光毁灭记忆、已成空白 提交于 2019-12-25 09:36:59
问题 I have made a FragmentActivity. Some Fragments include an EditText . I would like, when the Soft Input Keyboard is up and a MotionEvent happens - except the Event of clicking inside the EditText - the Soft Input to hide. Until now I wrote this code in my MainActivity: @Override public boolean dispatchTouchEvent(MotionEvent ev) { InputMethodManager im = (InputMethodManager) getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(getWindow()