I have ViewGroup implementation, but it works as a component, not a container. Okay, when user scrolls control it should scroll all its children in different direction.
So interaction scheme is:
|| MotionEvent
\/
My Control
/|\
/ | \
/ | \ message clones
/ | \
Child1 Ch2 Child3
How can I implement that scheme?
Unworked variant:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
boolean intercepted = false;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child instanceof ViewGroup ) {
intercepted |= ((ViewGroup) child).onInterceptTouchEvent(ev);
}
}
return super.onInterceptTouchEvent(ev) || intercepted;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
boolean intercepted = false;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
intercepted |= child.onTouchEvent(ev);
}
return super.onTouchEvent(ev) || intercepted;
}
That variant also doesn't work:
private void dispatchTouch(MotionEvent ev) {
for(int i = 0; i < getChildCount(); i++){
getChildAt(i).dispatchTouchEvent(ev);
}
}
What should I do?
0 comments:
Post a Comment