参见英文答案 >
Strange out of memory issue while loading an image to a Bitmap object41个
我想在我的Android应用程序中实现启动页面.所以在布局xml中,有一个imageView,而图像文件是一个1080 * 1920的png文件,当运行应用程序时,它会发生OutOfMemoryError错误,我该如何解决?
我想在我的Android应用程序中实现启动页面.所以在布局xml中,有一个imageView,而图像文件是一个1080 * 1920的png文件,当运行应用程序时,它会发生OutOfMemoryError错误,我该如何解决?
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/welcome1"/>
</LinearLayout>
错误信息:
04-17 18:40:16.038 29793-29793/cn.test.android E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: cn.test.android,/uploads/20230727/4f52b2d358f1f470623cdc7a6bba71b2.png,请将其放在drawable-nodpi中.这是因为drawable被解释为drawable-mdpi,因此当你将它加载到更高密度的手机上时,它将被放大(成为一个巨大的位图).