I have an array of imageViews inside a linearlayout inside a scrollivew. The imageviews have onTouchEvent and get DOWN touch event when scrolling. I need a method so I can scroll without the views intercepting DOWN event.
Child touch listener
image.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
Animation scale = new ScaleAnimation(1f, 0.5f, 1f, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
scale.setInterpolator(new DecelerateInterpolator());
scale.setFillEnabled(true);
scale.setFillBefore(true);
scale.setFillAfter(true);
scale.setDuration(300);
v.startAnimation(scale);
image.getParent().getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
image.getParent().getParent().requestDisallowInterceptTouchEvent(false);
scale = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
scale.setInterpolator(new OvershootInterpolator());
scale.setFillEnabled(true);
scale.setFillBefore(true);
scale.setFillAfter(true);
scale.setDuration(200);
scale.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
toggle();
}
});
image.startAnimation(scale);
mPager.setCurrentItem(image.getId(), false);
v.performClick();
break;
case MotionEvent.ACTION_CANCEL:
scale = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
scale.setInterpolator(new OvershootInterpolator());
scale.setFillEnabled(true);
scale.setFillBefore(true);
scale.setFillAfter(true);
scale.setDuration(200);
scale.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
toggle();
}
});
image.startAnimation(scale);
mPager.setCurrentItem(image.getId(), false);
v.performClick();
break;
}
return true;
}
});