您需要在 1 个布局中添加 2 个滚动视图(如 Royston 所说)(结果是在某些手机上它看起来很滞后)这是一些代码片段:首先在 xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/myparentScrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ScrollView
android:id="@+id/mychildScrollView"
<TextView
/ >
</ScrollView>
并将其添加到后面的代码中
parentScrollView= (ScrollView) findViewById(R.id.myparentScrollview);
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
//Log.v(TAG,"PARENT TOUCH");
findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView= (ScrollView) findViewById(R.id.childScrollView);
childScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
//Log.v(TAG,"PARENT TOUCH");
findViewById(R.id.mychildScrollView).getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});