xml布局文件:
<ScrollView
android:id="@+id/programPlayParentScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:focusableInTouchMode="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="@+id/programPlayMusicListScroll"
android:layout_width="match_parent"
android:layout_height="100dp"
android:scrollbars="none"
android:layout_marginTop="80dp"/>
</LinearLayout>
</ScrollView>
MainActivity.java onCreate文件:
ScrollView programPlayParentScroll, programPlayMusicListScroll;
programPlayParentScroll = (ScrollView) findViewById(R.id.programPlayParentScroll);
programPlayMusicListScroll = (ScrollView) findViewById(R.id.programPlayMusicListScroll);
programPlayParentScroll.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
programPlayMusicListScroll.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
programPlayMusicListScroll.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
view.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});