【问题标题】:ImageView not Showing Some DevicesImageView 不显示某些设备
【发布时间】:2016-03-06 03:58:47
【问题描述】:

我想展示一张带有ImageView 的图片。但是我的图片尺寸是 618 * 12956。

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/imageViewKonu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:scaleType="fitXY" />
</ScrollView>

在 GT-5830 上看起来不错。但是用 HTC Desire 820 滑动时卡住了。用 Note 3 不显示。我该怎么做才能让所有设备都显示流畅?

【问题讨论】:

    标签: android imageview


    【解决方案1】:

    该图像将消耗 30.5MB 的堆空间(假设位深度的默认 ARGB_8888 值为 4 字节/像素)。有很多设备你的整个应用没有 30.5MB 的堆空间,更不用说单个块那么大了。因此,您将在许多设备上使用OutOfMemoryError 崩溃。

    您将需要使用仅在任何时候都需要的图像部分加载的东西,而不是ScrollView 内的ImageViewDave Morrissey's SubsamplingScaleImageView 就是一个例子。

    【讨论】:

    • 谢谢,但它看起来像i.hizliresim.com/MpgnAg.png,但我想要hizliresim.com/Wk9ML8
    • @SerhatHacıoğlu:查看configuration documentation 看看您可能需要什么。即使这个特定的小部件无法处理它,你也需要一些类似的东西,所以你不会一次加载整个图像。
    • 我什么也做不了。问题还在继续
    • @SerhatHacıoğlu:然后与开发人员交谈。或者,编写您自己的等价物来处理您的用例。或者,四处寻找另一个候选库。或者,重新设计您的 UI,使其不包含大量图像。
    猜你喜欢
    • 1970-01-01
    • 2014-10-22
    • 2016-10-08
    • 1970-01-01
    • 2019-10-29
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多