Sunday, February 23, 2014

HorizontalScrollView + ListView scrolling problem


HorizontalScrollView inside a ListView
HorizontalScrollView and ListView are using android comes
Now to achieve the effect is very smooth when sliding around but it is very awkward slide up and down, sometimes uncontrolled slide will go around.
Members seeking big polytheism how to solve.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
This is a ScrollView and HorizontalScrollView rolling conflict. Solve more trouble.
Here you find a way in stackFlow try a custom ScrollView
 
public class CustomScrollView extends ScrollView {
private GestureDetector mGestureDetector;
View.OnTouchListener mGestureListener;

public CustomScrollView (Context context, AttributeSet attrs) {
super (context, attrs);
mGestureDetector = new GestureDetector (context, new YScrollDetector ());
setFadingEdgeLength (0);
}

@ Override
public boolean onInterceptTouchEvent (MotionEvent ev) {
return super.onInterceptTouchEvent (ev) && mGestureDetector.onTouchEvent (ev);
}

/ / Return false if we're scrolling in the x direction
class YScrollDetector extends SimpleOnGestureListener {
@ Override
public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (Math.abs (distanceY)> Math.abs (distanceX)) {
return true;
}
return false;
}
}
}

Reply:
cited a floor birdsaction reply:
this is ScrollView and HorizontalScrollView rolling conflict. Solve more trouble.
Here you find a way in stackFlow try a custom ScrollView
 
public class CustomScrollView extends ScrollView {
private GestureDetector mGestureDetector;
View.OnTouchListener mGestureListener;

public CustomScrollView (Context context, AttributeSet attrs) {
super (context, attrs);
mGestureDetector = new GestureDetector (context, new YScrollDetector ());
setFadingEdgeLength (0);
}

@ Override
public boolean onInterceptTouchEvent (MotionEvent ev) {
return super.onInterceptTouchEvent (ev) && mGestureDetector.onTouchEvent (ev);
}

/ / Return false if we're scrolling in the x direction
class YScrollDetector extends SimpleOnGestureListener {
@ Override
public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (Math.abs (distanceY)> Math.abs (distanceX)) {
return true;
}
return false;
}
}
}


Positive solution. . .
 
if (Math.abs (distanceY)> Math.abs (distanceX)) {
return true;
}
The judgment is greater than the cross-slip slide mobile is moving on to determine the slip

Reply:
Try to avoid this practice two slide together easily interfere with, difficult to deal with is perfect.
Reply:
The reply was deleted administrator at 2013-11-06 15:10:50

No comments:

Post a Comment