下面列出了android.support.v4.view.NestedScrollingChild#android.support.v4.view.ScrollingView 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private View findScrollableViewInternal(View content, boolean selfable) {
View scrollableView = null;
Queue<View> views = new LinkedBlockingQueue<>(Collections.singletonList(content));
while (!views.isEmpty() && scrollableView == null) {
View view = views.poll();
if (view != null) {
if ((selfable || view != content) && (view instanceof AbsListView
|| view instanceof ScrollView
|| view instanceof ScrollingView
|| view instanceof NestedScrollingChild
|| view instanceof NestedScrollingParent
|| view instanceof WebView
|| view instanceof ViewPager)) {
scrollableView = view;
} else if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
for (int j = 0; j < group.getChildCount(); j++) {
views.add(group.getChildAt(j));
}
}
}
}
return scrollableView;
}
/**
* Find out the scrollable child view from a ViewGroup.
*/
private void findScrollView(ViewGroup viewGroup) {
scrollChild = viewGroup;
if (viewGroup.getChildCount() > 0) {
int count = viewGroup.getChildCount();
View child;
for (int i = 0; i < count; i++) {
child = viewGroup.getChildAt(i);
if (child instanceof ScrollingView ||
child instanceof AbsListView ||
child instanceof ScrollView ||
child instanceof ViewPager ||
child instanceof WebView) {
scrollChild = child;
return;
}
}
}
}
/**
* is video controllerView in 'list' controllerView
*
* @return
*/
public boolean inListView() {
for (ViewParent vp = getParent(); vp != null; vp = vp.getParent()) {
if (vp instanceof AbsListView || vp instanceof ScrollingView || vp instanceof ScrollView) {
return true;
}
}
return false;
}