Created
February 9, 2018 19:19
-
-
Save mrenouf/33ffe69f79f0c8d91e1ffd028dd46985 to your computer and use it in GitHub Desktop.
NonGreedyNestedScrollView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mrenouf.touchtest; | |
import android.content.Context; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.support.v4.widget.NestedScrollView; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
public class NonGreedyNestedScrollView extends NestedScrollView { | |
public NonGreedyNestedScrollView(@NonNull Context context) { | |
this(context, null, 0); | |
} | |
public NonGreedyNestedScrollView(@NonNull Context context, @Nullable AttributeSet attrs) { | |
this(context, attrs, 0); | |
} | |
public NonGreedyNestedScrollView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent event) { | |
if (event.getActionMasked() == MotionEvent.ACTION_DOWN | |
&& !ViewGroups.isTopChildUnder(this, event.getX(), event.getY())) { | |
return false; | |
} | |
return super.onInterceptTouchEvent(event); | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
if (event.getActionMasked() == MotionEvent.ACTION_DOWN | |
&& !ViewGroups.isTopChildUnder(this, event.getX(), event.getY())) { | |
return false; | |
} | |
return super.onTouchEvent(event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment