【发布时间】:2012-04-29 09:55:05
【问题描述】:
我正在实现一个小部件,我试图在图像视图 (8mpx) 中显示一个大图像,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" android:id="@+id/widget"
android:background="#000000"
android:padding="15dp"
android:layout_margin="5dp"
android:layout_gravity="top|center_vertical|center_horizontal"
>
<LinearLayout android:background="#ffffff" android:padding="1dp" android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content" >
<ImageView
android:adjustViewBounds="true"
android:id="@+id/image"
android:src="@drawable/sample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="top|center_horizontal"
android:scaleType="fitXY"
android:maxWidth="200dip"
android:maxHeight="300dip"
/>
</LinearLayout>
在模拟器中一切似乎都很好,但是当我部署到设备时,我收到“加载小部件问题”消息。 模拟器是 HVGA,我的设备有 480x800 分辨率。 知道我在做什么错吗?
谢谢!
================================================ ===
根据你们的建议,我制作了 logcat 的屏幕截图。 这里是:
【问题讨论】:
-
嗨!是的,我想显示调整大小的完整图像(同时保持纵横比)
-
您能否使用 logcat 的完整错误输出来编辑您的问题?另外,你用的是硬件加速吗?如果您尝试将其关闭,看看会发生什么。我尝试使用硬件加速加载非常大的图像,并且出现一个静默的 OpenGL 错误,抱怨没有足够的内存来加载图像,并且此错误仅显示在 logcat 输出中。
-
是的,logcat 中的错误似乎与内存有关...
-
这个问题听起来很像...stackoverflow.com/questions/6265008/…