많은 Childs가있는 전망이 있습니다. 내가 필요한 것은 스 와이프 또는 플링 동작에 대한 반응을 구현하는 것입니다. 문제는 모든 하위 항목을 제거하는 경우에만 실제로 작동한다는 것입니다. 그렇지 않으면 기본 레이아웃 상단의 하위보기가 스 와이프 시도를 차단합니다.overlying views를 무시하고 onFling (onSwipe)를 감지하는 방법은 무엇입니까?
주 레이아웃에 onSwipeListener를 추가하고 GestureListener를 동일한 성공으로 전체 활동에 추가하는 방법을 시도했습니다.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schedule);
main_layout = findViewById(R.id.schedule_main_view);
Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade);
main_layout.startAnimation(fadeInAnimation);
GestureDetector.SimpleOnGestureListener simpleOnGestureListener =
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDown(MotionEvent event) {
return true;
}
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2,
float velocityX, float velocityY) {
Log.d(null,"Fling");
int dx = (int) (event2.getX() - event1.getX());
// don't accept the fling if it's too short
// as it may conflict with a button push
if (Math.abs(dx) > 20
&& Math.abs(velocityX) > Math.abs(velocityY)) {
if (velocityX > 0) {
Log.d(DEBUG_TAG, "onFling: " + event1.toString() + event2.toString());
Log.d(DEBUG_TAG, "onFling To Right");
} else {
Log.d(DEBUG_TAG, "onFling: " + event1.toString() + event2.toString());
Log.d(DEBUG_TAG, "onFling To Left");
}
return true;
} else {
return false;
}
}
};
shift = getIntent().getIntExtra(WEEK_SHIFT, CURRENT_WEEK);
mDetector = new GestureDetectorCompat(this,simpleOnGestureListener);
unDimScreen();
setupWeek();
}
가 반복하려면 : 같은
나의 현재 (비 작동) 솔루션은 보이는 상단에 자식 뷰가없는 경우 활동이 상태에있는 경우, 의도 한대로 작동.
그래서 질문은 : 활동보기 가져 오기가 위의보기를 무시하도록하려면 어떻게해야합니까?
ViewGroup에서 Intercept Touch Events가 필요한 항목입니다. 고맙습니다! –