建议我避免安卓内存不足错误的好方法



我是安卓新手,请向我建议一种优化图像的好方法或一些我用来在我的应用程序中设置图像而不会出错的库......

任何善意的帮助表示赞赏。

感谢任何提前:)

其实这取决于

1). 如果您在回收视图、网格视图等中显示基于 URL 的图像。

您可以根据需要使用图像加载器库

以下是选择您要使用的库链接:

滑行:https://github.com/bumptech/glide

毕加索:https://github.com/square/picasso

通用图像加载器:https://github.com/nostra13/Android-Universal-Image-Load

现在选择哪个我个人建议glide.如果你想加载大尺寸的图像,而不是使用通用图像加载器,如果你想使用小图像,而不是去毕加索

2). 如果要在不同的地方使用相同的位图,则可以使用位图缓存

位图缓存技术

  1. 鲁缓存
  2. 磁盘缓存

3).一些可以帮助您解决内存不足错误的设置:

在清单文件中,您可以设置 largeHeap="true"

<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="Mall"
android:largeHeap="true"
android:logo="@drawable/logo_for_up"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" >
</application>

希望这个答案对你有帮助。如果您需要任何其他帮助,可以要求

最新更新