crocboy
crocboy

Reputation: 414

Android LinearLayout Multi-Touch

I am using LinearLayout's to represent different parts of my UI. The idea is that these layouts will be in a grid arrangement. In addition, the user will be able to drag the windows around to re-arrange them. I started by creating my layouts, and everything works great. Then I applied an OnTouchListener to my views:

 touchListener = new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.e("VARS","MotionEvent!");
                if(event.getPointerCount() == 2) {
                Log.e("VARS","It's two!");

                }
                return false;
            }
        };

It completely ignores the case where event.getPointerCount() is two! It seems that this method is only invoked when the pointer count is one. I put this in my manifest:

<uses-feature android:name="android.hardware.touchscreen.multitouch"/>

and it still doesn't work. Does LinearLayout have a special case where only MotionEvent's with a pointer count of one are recognized, or is there something else I'm missing?

Upvotes: 0

Views: 392

Answers (2)

crocboy
crocboy

Reputation: 2887

You need to change return false to return true. By consuming the MotionEvent, it will work correctly.

Upvotes: 1

Tom-Oliver Heidel
Tom-Oliver Heidel

Reputation: 1131

http://developer.android.com/reference/android/view/MotionEvent.html#getPointerCount%28%29

You cannot set it higher than 1. It doesnt have something to do with linearlayout.

Upvotes: 0

Related Questions