当前位置: 移动技术网 > IT编程>移动开发>Android > Android放置图片内存溢出处理方法

Android放置图片内存溢出处理方法

2018年09月14日  | 移动技术网IT编程  | 我要评论

错嫁寡情总裁放开我,大学生情感问题,果照门

app\src\main\res\mipmap-hdpi,不要放进drawable文件夹)
xml version="1.0" encoding="utf-8">

<framelayout xmlns:android="https://schemas.android.com/apk/res/android"

 xmlns:app="https://schemas.android.com/apk/res-auto"

 xmlns:tools="https://schemas.android.com/tools"

 android:layout_width="match_parent"

 android:layout_height="match_parent"

 tools:context=".framelayoutapp"

 imageview

 android:id="@+id/imageview"

 android:layout_width="wrap_content"

 android:layout_height="406dp"

 app:srccompat="@mipmap/photos"

 android:layout_gravity="center"
 imageview
 android:id="@+id/imageview2"

 android:layout_width="206dp"

 android:layout_height="179dp"

 android:layout_gravity="center"

 app:srccompat="@mipmap/pictures" />

framelayout>

方法二(将图片放入app\src\main\res\drawable时)

xml version="1.0" encoding="utf-8">
<framelayout xmlns:android="https://schemas.android.com/apk/res/android"
 xmlns:app="https://schemas.android.com/apk/res-auto"
 xmlns:tools="https://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".framelayoutapp"
 imageview
 android:id="@+id/imageview"
 android:layout_width="wrap_content"
 android:layout_height="406dp"
 app:srccompat="@drawable/photos"
 android:layout_gravity="center"
 imageview
 android:id="@+id/imageview2"
 android:layout_width="206dp"
 android:layout_height="179dp"
 android:layout_gravity="center"
 app:srccompat="@drawable/pictures" />
framelayout>
会出现内存溢出问题
关于java.lang.outofmemoryerror: failed to allocate a 127844364 byte allocation with 16768792 free bytes and 63mb until oom
在androidmanifest中的application加入以下代码:
android:hardwareaccelerated="false"
android:largeheap="true" //申请更多的内存

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网