app\src\main\res\mipmap-hdpi,不要放进drawable文件夹)
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://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="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://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" //申请更多的内存