Android Pinch使用ScrollView缩放ImageView(PhotoView)

时间:2014-04-27 19:33:34

标签: android imageview

我在android中有以下布局,其中我基本上有一个图像视图,其复合字幕包含其他图像视图+ textviews:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

    <RelativeLayout
            android:id="@+id/imagePager_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <uk.co.senab.photoview.PhotoView
                android:id="@+id/imagePager_imageView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        <TextView
                android:id="@+id/imagePager_textTitle"
                android:layout_width="fill_parent"
                android:gravity="center"
                android:textStyle="bold"
                android:text="TITLE"
                android:layout_margin="0dp"
                android:layout_below="@+id/imagePager_imageView"
                android:layout_height="wrap_content"/>

        <ImageView android:id="@+id/imagePager_titleLine"
                   android:layout_width="fill_parent"
                   android:layout_below="@+id/imagePager_textTitle"
                   android:layout_height="match_parent"
                   android:paddingLeft="5dp"
                   android:paddingRight="5dp"
                   android:src="@drawable/linebig"/>

        <TextView
                android:id="@+id/imagePager_textSubtitle"
                android:layout_width="fill_parent"
                android:gravity="center"
                android:text="SUBTITLE"
                android:layout_margin="0dp"
                android:layout_below="@+id/imagePager_titleLine"
                android:layout_height="wrap_content"/>

        <ImageView android:id="@+id/imagePager_subtitleLine"
                   android:layout_below="@+id/imagePager_textSubtitle"
                   android:layout_width="fill_parent"
                   android:layout_height="match_parent"
                   android:paddingLeft="30dp"
                   android:paddingRight="30dp"
                   android:paddingBottom="10dp"
                   android:src="@drawable/linebig"/>

        <TextView
                android:id="@+id/imagePager_textContent"
                android:layout_width="fill_parent"
                android:paddingTop="15dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="CONTENT"
                android:layout_margin="0dp"
                android:layout_below="@+id/imagePager_subtitleLine"
                android:layout_height="wrap_content"/>


    </RelativeLayout>
</ScrollView>

问题在于,如果整个内容如此长,那么&#34; ScrollView已启用,Pinch Zoom无效。否则它完美无缺。我想ScrollView听众会考虑&#34; Pinch&#34;和上/下运动。有人有解决方案吗?

1 个答案:

答案 0 :(得分:0)

将滚动视图更改为android.support.v4.widget.NestedScrollView