How can I make when sliding in ViewPager ScrollView not scroll .
ScrollView tried rewriting the onTouchEvent, but to no avail.
------ Solution ---------------------------------------- ----
the problem I have encountered , could not find a good way , and finally I put ScrollView deleted , if we want to keep it proposed to achieve
------ reference ---- GroupView -----------------------------------
already own implementation , the need to rewrite ScrollView, the following is code
package com.zp365.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ScrollView;
/**
* 解决ScrollView嵌套ViewPager出现的滑动冲突问题
*/
public class ScrollView1 extends ScrollView {
private boolean canScroll;
private GestureDetector mGestureDetector;
View.OnTouchListener mGestureListener;
public ScrollView1(Context context, AttributeSet attrs) {
super(context, attrs);
mGestureDetector = new GestureDetector(new YScrollDetector());
canScroll = true;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if(ev.getAction() == MotionEvent.ACTION_UP)
canScroll = true;
return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
}
class YScrollDetector extends SimpleOnGestureListener {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if(canScroll)
if (Math.abs(distanceY) >= Math.abs(distanceX))
canScroll = true;
else
canScroll = false;
return canScroll;
}
}
}
ScrollView with this custom ScrollView on the line instead of the original
------ reference ------------------------- --------------
Great God I ask how to call a custom scroll it ? Not directly defined in the xml before , and now need how to call it ?
------ reference --------------------------------------- < br> Great God really to force , quite so!
------ reference --------------------------------------- < br> top Great God
------ reference - --------------------------------------
top Great God ! ! !
------ reference --------------------------------------- < br> If yes tgyhrfuj741 said, although can be achieved, but sliding around scrollview not useful , I am now the main problem is that there is a lateral view of the sliding scrollview subview has a slide up and down scrollview, embedded in a child view viewpager, but viewpager sliding around events and outermost sliding around scrollview event of a conflict , ask how to solve
没有评论:
发表评论