6

我想在不调整图像大小的情况下显示比设备屏幕更大的图像。它必须在屏幕上居中。我怎样才能做到这一点?

4

4 回答 4

7

使用带有图像视图的滚动视图并设置该滚动视图的高度

例子

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <ImageView
        android:id="@+id/accountIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</ScrollView>
于 2011-06-23T07:28:01.930 回答
5

我注意到我需要使用正常(垂直)和水平 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_gravity="center" 那么我在右侧或底部得到白色部分。所以居中对我不起作用。

选项 2:使用 WebView 控件,并使用图像 onCreate 加载它。

于 2015-03-22T23:02:59.887 回答
0

从 View 派生,覆盖 onDraw 并将其绘制在屏幕上。

于 2011-06-23T07:12:49.267 回答
0

您还可以使用框架布局。布局可以比屏幕大

于 2015-03-22T23:35:21.210 回答