你真的知道drawable和mipmap的区别吗?
代码一:图片放在mipmap下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_image">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/galery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/gallery_66" />
<ImageView
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:src="@mipmap/camera_56" />
</LinearLayout>
<ImageView
android:id="@+id/editedImages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:src="@mipmap/mag" />
</LinearLayout>
</RelativeLayout>
代码一对应效果如下

代码二:图片放在drawable下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_image">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/select_ablum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gallery_66" />
<ImageView
android:id="@+id/take_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:src="@drawable/camera_56" />
</LinearLayout>
<ImageView
android:id="@+id/edit_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:src="@drawable/mag" />
</LinearLayout>
</RelativeLayout>
代码二对应效果如下


博客围绕drawable和mipmap的区别展开,通过展示图片分别放在mipmap和drawable下的代码及对应效果,引导读者了解二者差异,属于前端开发中资源处理相关内容。
358

被折叠的 条评论
为什么被折叠?



