Android疑难杂证-解决ViewPager和Fragment中水平滑动控件冲突问题

  1. 1. 终极解决方案

终极解决方案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import zhouzhuo810.me.zzandframe.ui.widget.ZzViewPager;

/**
* Created by zhouzhuo810 on 2018/4/11.
*/
public class NoConflictViewPager extends ZzViewPager {
public NoConflictViewPager(Context context) {
super(context);
}

public NoConflictViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
//这里添加冲突的控件类型
if (v instanceof PickerView) {
return true;
}
return super.canScroll(v, checkV, dx, x, y);
}
}