在ImageView下滚动ScrollView

时间:2016-07-19 14:48:29

标签: android scrollview ontouchlistener

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

<?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>

如果是的话,怎么做?

2 个答案:

答案 0 :(得分:3)

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

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

答案 1 :(得分:0)

看起来它没有任何额外的代码可以工作:) Video approve

相关问题