我正在尝试将图像加载到ImageVIEw中并收到OutOfMemoryError.该图像根据VIEwPager中的特定视图动态显示.但是,在我继续滚动浏览VIEwPager之后,图像最终无法加载,并导致OutOfMemoryError.
请注意,我在VIEwPager中有4个视图,并且该应用程序似乎在视图2上崩溃.我猜想图像只是尺寸过大,但我的印象是毕加索会相应地处理:
毕加索代码:
Picasso.with(getActivity()) .load(mImageURL) .fit() .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_CACHE) .into((ImageVIEw) rootVIEw.findVIEwByID(R.ID.comments_image));
XML格式
<ImageVIEw androID:ID="@+ID/comments_image" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight=".525" androID:background="@color/black"></ImageVIEw>
错误
java.lang.OutOfMemoryError: Failed to allocate a 5074572 byte allocation with 132096 free bytes and 129KB until OOM at dalvik.system.vmruntime.newNonMovableArray(Native Method) at androID.graphics.Bitmap.nativeCreate(Native Method) at androID.graphics.Bitmap.createBitmap(Bitmap.java:812) at androID.graphics.Bitmap.createBitmap(Bitmap.java:789) at androID.graphics.Bitmap.createBitmap(Bitmap.java:756) at androID.graphics.drawable.VectorDrawable$VectorDrawableState.createCachedBitmAPIfNeeded(VectorDrawable.java:713) at androID.graphics.drawable.VectorDrawable.draw(VectorDrawable.java:280) at com.squareup.picasso.PicassoDrawable.draw(PicassoDrawable.java:105) at androID.Widget.ImageVIEw.onDraw(ImageVIEw.java:1176) at androID.vIEw.VIEw.draw(VIEw.java:15231) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14167) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.draw(VIEw.java:15234) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14167) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.support.design.Widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1131) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.draw(VIEw.java:15234) at androID.support.v4.vIEw.VIEwPager.draw(VIEwPager.java:2341) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14167) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.support.v4.Widget.DrawerLayout.drawChild(DrawerLayout.java:1373) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.updatedisplayListIfDirty(VIEw.java:14162) at androID.vIEw.VIEw.getdisplayList(VIEw.java:14189) at androID.vIEw.VIEw.draw(VIEw.java:14959) at androID.vIEw.VIEwGroup.drawChild(VIEwGroup.java:3405) at androID.vIEw.VIEwGroup.dispatchDraw(VIEwGroup.java:3198) at androID.vIEw.VIEw.draw(VIEw.java:15234) at androID.Widget.FrameLayout.draw(F
解决方法:
您是否在清单文件中做了androID:largeheap =“ true”?
<application androID:name=".MyApplication" androID:allowBackup="true" androID:icon="@drawable/ic_launcher" androID:label="MyApplication" androID:largeHeap="true"* androID:logo="@drawable/logo_for_up" androID:screenorIEntation="portrait" androID:theme="@style/Apptheme" ></application>
总结 以上是内存溢出为你收集整理的使用Picasso图像的Java OutOfMemoryError全部内容,希望文章能够帮你解决使用Picasso图像的Java OutOfMemoryError所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)