motionevent

Pass motion event to parent Scrollview when Listview at top/bottom

和自甴很熟 提交于 2019-11-29 06:38:51
I have a ListView in a ScrollView to show comments and I would like to do the following: When the user swipes down, first the ScrollView should fully scroll down as the list is at the bottom. Once it's fully down, the Listiew should start scrolling. Similarly, when the user is scrolling up, first the ListView (order reversed here!) should scroll up, before the ScrollView starts scrolling. So far I have done the following: listView.setOnTouchListener(new View.OnTouchListener() { // Setting on Touch Listener for handling the touch inside ScrollView @Override public boolean onTouch(View v,

How to keep an image within layout with drag and drop

耗尽温柔 提交于 2019-11-29 05:21:36
I have the following XML: <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/palette2" android:id="@+id/fl" > <ImageView android:id="@+id/iv" android:layout_width="10dp" android:layout_height="10dp" android:src="@drawable/esquare" /> </FrameLayout> Which gives the following image in my Android Phone How can I code so that user can drag the image anywhere in a layout and the ImageView will always stay within the layout? If X<0 it will be X=(X+imageview.width()) If Y<0 it will be Y=(Y+imageview.height()) If X>layout.width() it will

MotionEvent handling in ScrollView in Android

放肆的年华 提交于 2019-11-29 04:51:56
I've been trying to figure out the behavior of MotionEvents in ScrollViews in Android and there's something i can't figure out. As an example I made an Activity that has a ScrollView inside of it and the ScrollView has a LinearLayout inside of it. I implemented my own classes to have control over the touch-related functions: public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MyInnerLayout inner = new MyInnerLayout(getApplicationContext()); MyLayout layout = new

In Android, what is the difference between getAction() and getActionMasked() in MotionEvent?

折月煮酒 提交于 2019-11-29 00:22:29
问题 I am confused by the two methods in Android. It seems that both methods tell you what kind of event it is, i.e., whether it is a down or up event. When will I use which? public void onTouchEvent(MotionEvent e) Don't quote the documentation please, because I read it, and I don't see any parameter I can supply to either of the methods to get something different. public final int getAction () and public final int getActionMasked() 回答1: Yes, they both return the action (up/down etc.), but

How to keep an image within layout with drag and drop

﹥>﹥吖頭↗ 提交于 2019-11-27 23:08:48
问题 I have the following XML: <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/palette2" android:id="@+id/fl" > <ImageView android:id="@+id/iv" android:layout_width="10dp" android:layout_height="10dp" android:src="@drawable/esquare" /> </FrameLayout> Which gives the following image in my Android Phone How can I code so that user can drag the image anywhere in a layout and the ImageView will always stay within the layout? If X<0 it

MotionEvent handling in ScrollView in Android

淺唱寂寞╮ 提交于 2019-11-27 18:37:32
问题 I've been trying to figure out the behavior of MotionEvents in ScrollViews in Android and there's something i can't figure out. As an example I made an Activity that has a ScrollView inside of it and the ScrollView has a LinearLayout inside of it. I implemented my own classes to have control over the touch-related functions: public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

Android finger detection - Orientation and ellipse

廉价感情. 提交于 2019-11-27 15:21:39
I've been looking for a way to detect the finger orientation together with a simplification of the touch area in the form of an ellipse, when using a mobile touch device. I choose Android rather than iOS since I found three usefull methods ( getTouchMajor() , getTouchMinor() , and getOrientation() ) in the Android reference for the MotionEvent class . But I've tried to implement these three methods in my app, and sadly they does not return the wanted values. The orientation stays at 0, no matter what, while the getTouchMajor and getTouchMinor is exactly the same each time. So my question is:

android drag and drop ImageView onTouchListener

泪湿孤枕 提交于 2019-11-27 03:38:30
问题 Hello I've set up an onTouchListener within my application for an ImageView, my aim was to have an ImageView that the user would be able to drag around and place where ever they want within the app. I've written some code using sample code found on the web for an onTouchListener that I thought would work but I'm having some problems with it, rather than allowing me to drag the image around, the image resizes and gets bigger or smaller when you drag your finger over it. Does anyone have any

Get button coordinates and detect if finger is over them - Android

烂漫一生 提交于 2019-11-26 11:16:54
问题 I have 4 buttons in my android app activity. This is what it looks like: As you can see, the textViews at the bottom of the screen display the x and y coordinates. The coordinates are in reference to a relative layout. (See below given code) Now, what I want to do is get the x and y coordinates of the 4 buttons at runtime and then figure out if my finger is touching the buttons while moving or not. In simple words, I want to press the buttons by swiping my finger over them instead of lifting