您的位置:首页 > 产品设计

你真的知道drawable和mipmap的区别吗

2019-06-18 16:59 246 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/codehxy/article/details/92796125

你真的知道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>

代码二对应效果如下

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: