Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于滑动冲突的问题 #50

Open
aa563011992 opened this issue May 8, 2018 · 0 comments
Open

关于滑动冲突的问题 #50

aa563011992 opened this issue May 8, 2018 · 0 comments

Comments

@aa563011992
Copy link

aa563011992 commented May 8, 2018

测试发现,如果代码中存在listview等可滚动控件,且没有放到布局代码的第一层(如下即为放到第一层)

tim 20180508173859

会存在滑动冲突问题,然而实际应用中,布局肯定十分复杂,很难直接放于第一层
研究源码发现代码中有这样一个方法 findScrollView,是用来寻找布局中可滚动的控件,但仅找了第一层,所以会出现以上问题
尝试将该方法改为递归后解决问题:即从整个布局代码中寻找滚动控件,但如果布局中存在多个滚动控件的话,可能会出问题
代码如下

private View findScrollView(ViewGroup viewGroup) {
View child = viewGroup;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
child = viewGroup.getChildAt(i);
if (child instanceof AbsListView || child instanceof ScrollView || child instanceof ViewPager || child instanceof WebView) {
return child;
} else if (child instanceof ViewGroup) {
child = findScrollView((ViewGroup) child);
if (child instanceof AbsListView || child instanceof ScrollView || child instanceof ViewPager || child instanceof WebView) {
return child;
} else {
continue;
}
} else {
continue;
}
}
return child;

}

tim 20180508174030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant