Android Studio 3.0中res目录中的mipmap-anydpi-v26是什么? [英] What's mipmap-anydpi-v26 in res directory in Android Studio 3.0?

查看:873
本文介绍了Android Studio 3.0中res目录中的mipmap-anydpi-v26是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio 3.0中,一旦我们创建了项目,就会在res目录中自动创建一个名为mipmap-anydpi-v26的文件夹.它实际上是做什么的?我们为什么需要它?我们将如何将其用于开发目的?

In Android Studio 3.0, once we create a project, a folder named mipmap-anydpi-v26 is automatically created in the res directory. What actually does it do? Why do we need it? How will we utilize it for development purposes?

此外,在项目设置后,将在此文件夹中自动创建两个XML文件.为什么这些XML文件驻留在mipmap文件夹中?我认为我们应该将所有XML文件都保留在可绘制的文件夹中,而不要放在mipmap中.

Also, there are two XML files automatically created in this folder after project setup. Why do these XML files reside in a mipmap folder? I thought we should keep all XML files in a drawable folder instead of mipmap.

推荐答案

Android Studio 3创建一个自适应图标,仅在SDK 26及更高版本中可用.启动器图标应放在mipmap文件夹中.

Android Studio 3 creates an adaptive icon for your app which is only available in SDK 26 and up. Launcher icons should be put into the mipmap folders.

如果您查看清单,则可以看到它引用了ic_launcher

If you look at your manifest, you can see that it references ic_launcher

android:icon="@mipmap/ic_launcher"

如果您在mipmap文件夹中查找,则会看到正常的5个不同的启动器图标,这些图标将用于低于SDK 26的任何东西.对于SDK 26及更高版本,它将使用anydpi-v26文件夹中的XML文件来使用自适应图标.

If you look in your mipmap folder, you see your normal 5 different launcher icons which will be used for anything lower than SDK 26. For SDK 26 and up, it uses the XML files from the anydpi-v26 folder to make use of adaptive icon.

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@drawable/ic_launcher_background"/>
    <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

这篇关于Android Studio 3.0中res目录中的mipmap-anydpi-v26是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆