您的位置:首页 > 移动开发 > Android开发

Android ScrollView嵌套ScrollView滚动的问题解决办法

2016-11-22 14:39 351 查看
布局中

<ScrollView

android:id="@+id/scrollview_parent"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:focusableInTouchMode="false"

android:scrollbars="none" >

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical" >

<ScrollView

android:id="@+id/scrollview_child"

android:layout_width="fill_parent"

android:layout_height="250dp"

android:layout_marginLeft="10dp"

android:layout_marginRight="10dp"

android:layout_marginTop="10dp"

android:scrollbars="none" >

</ScrollView>

</LinearLayout>

</ScrollView>

代码中。。。

parentScrollView.setOnTouchListener(new View.OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

findViewById(R.id.scrollview_child).getParent().requestDisallowInterceptTouchEvent(false);

return false;

}

});

childScrollView.setOnTouchListener(new View.OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event)

{

v.getParent().requestDisallowInterceptTouchEvent(true);

return false;

}

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: