当设置为 ImageView 时,图像的尺寸神奇地增加

Image magically increasing in dimensions when set to an ImageView

我正在将图像 (jpeg) 资源设置为尺寸为 877x3719 的 ImageView。然而,当我 运行 应用程序时,它告诉我:

W/OpenGLRenderer﹕ Bitmap too large to be uploaded into a texture (2631x11157, max=4096x4096)

这正好是原始图像尺寸的三倍。有谁知道在我的 java 代码中没有任何内容告诉它的情况下它如何或为什么将尺寸增加三倍? 下面是布局 XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView2" >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/testlay">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView1"
            android:contentDescription="@string/imageph" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView2"
            android:contentDescription="@string/imageph" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView3"
            android:contentDescription="@string/imageph" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView4"
            android:contentDescription="@string/imageph" />
    </LinearLayout>
</ScrollView>
</LinearLayout>

ImageView 的尺寸以 dips(设备独立像素)为单位测量,对于不同屏幕密度的设备(如常规和 "retina" iPhone),它可能会有所不同。

但是当我们为其设置图像时,为了获得最高质量,我们需要为每个 屏幕 像素分配值,这就是为什么您的图像尺寸为 "tripled" — 一个dip 有三个屏幕像素。