同步 ScrollView 和 NestedScrollView

Synchronizing ScrollView and NestedScrollView

我有以下布局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nestedscrollview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/inner_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <NESTED VIEWS>

            </LinearLayout>
        </android.support.v4.widget.NestedScrollView>

        <LinearLayout
            android:id="@+id/outer_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <OUTER VIEWS>

        </LinearLayout>
    </LinearLayout>
</ScrollView>

我的问题是我希望 ScrollView 先滚动,如果 ScrollView 移动了一点点,否则 NestedScrollView 可以消耗触摸。目前,NestedScrollView 获取触摸事件并仅在 ScrollView 接收到触摸之后才使用滚动。我试过使用 onInterceptTouchEvent 并进行了试验,但无济于事。有什么指点吗?

这是正确的方法还是我要使用其他视图组合? (可能是协调器布局?)

所以我扩展了 ScrollView 并使其工作如下:

private static final int SCROLL_THRESHOLD = 10;

private boolean mScrolling;

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (getScrollY() > SCROLL_THRESHOLD) {
        mScrolling = true;
        onTouchEvent(ev);
        return false;
    } else if (mScrolling) {
        mScrolling = false;
        return false;
    }
    if (ev.getActionMasked() == MotionEvent.ACTION_UP) {
        mScrolling = false;
    }
    return super.onInterceptTouchEvent(ev);
}

适合我。如果有人有更好的解决方案,请告诉我。