【问题标题】:Scroll ScrollView under ImageViewImageView下滚动ScrollView
【发布时间】:2016-07-20 15:07:13
【问题描述】:

是否可以使用手势滚动实际位于ImageView 下方的ScrollView
布局示例

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    <ScrollView
        android:id="@+id/sv_scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
             android:id="@+id/ll_content"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical">
             <!--..some content..-->
       </LinearLayout>
   </ScrollView>
   <ImageView
        android:id="@+id/iv_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/image"
        />
</FrameLayout>

如果有,该怎么做?

【问题讨论】:

    标签: android scrollview ontouchlistener


    【解决方案1】:

    您需要将 touchEvent 从 ImageView 传递给 ScrollView,如下所示。

    imageView.setOnTouchListener(new View.OnTouchListener() { 
        @Override 
        public boolean onTouch(View v, MotionEvent event) {
            return scrollView.onTouchEvent(event);
        } 
    }); 
    

    【讨论】:

      【解决方案2】:

      看起来它不需要任何额外的代码就可以工作:)
      Video approve.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多