Android 显示比设备大的图像';s屏幕

Android 显示比设备大的图像';s屏幕,android,image,resize,scroll,android-imageview,Android,Image,Resize,Scroll,Android Imageview,我想在不调整图像大小的情况下显示比设备屏幕大的图像。它必须在屏幕上居中。如何执行此操作?从视图派生,覆盖onDraw并在屏幕上绘制。将scrollview与图像视图一起使用,并设置该滚动视图的高度 例子 我注意到我需要使用普通(垂直)和水平滚动视图来双向滚动。如果有别的办法,请告诉我 <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android

我想在不调整图像大小的情况下显示比设备屏幕大的图像。它必须在屏幕上居中。如何执行此操作?

从视图派生,覆盖onDraw并在屏幕上绘制。

将scrollview与图像视图一起使用,并设置该滚动视图的高度

例子
我注意到我需要使用普通(垂直)和水平滚动视图来双向滚动。如果有别的办法,请告诉我

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollView" >
    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/horizontalScrollView">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/imageView3"
            android:src="@drawable/big_map"/>
        </HorizontalScrollView>
</ScrollView>

它从图像的左上角开始显示。若我尝试使用android:layout\u gravity=“center”,那个么我会在右边或底部看到白色部分。所以,居中对我来说不起作用


选项2:使用WebView控件,并在创建图像时将其加载。

您也可以使用framelayout。布局可以比屏幕大

这对我来说太棒了!唯一的问题是这样做后ImageView没有居中,所以我只需将
layout\u gravity=“center”
添加到ImageView。还要注意的是,在现代安卓系统中,它已被弃用,在任何情况下都可以安全地被替换(因为它们都做完全相同的事情)。
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollView" >
    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/horizontalScrollView">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/imageView3"
            android:src="@drawable/big_map"/>
        </HorizontalScrollView>
</ScrollView>