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

来源:互联网 发布:深圳云知空间有限公司 编辑:程序博客网 时间:2024/04/29 17:10

布局中

 <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; 
              } 
          }); 

0 0
原创粉丝点击