软件编程
位置:首页>> 软件编程>> Android编程>> Android Studio 3.0中mipmap-anydpi-v26是什么东东

Android Studio 3.0中mipmap-anydpi-v26是什么东东

作者:人言落日是天涯  发布时间:2023-10-11 01:17:44 

标签:android,studio,3.0,mipmap,anydpi,v26

在Android Studio 3.0中一旦我们创建了一个项目,一个名为mipmap-anydpi-v26自动创建的文件夹在res文件夹下。它究竟能干什么?为什么我们需要这个?我们在开发时该如何利用它?

另外,在项目创建之后,还会在此文件夹中创建两个xml文件。为什么这些文件在mipmap文件夹中?根据我们的理解,所有xml文件是保存在drawable目录下而不是mipmap中的。

Android Studio 3.0会为您的应用程序创建一个自适应图标,该图标仅在sdk 26中可用。启动图标应放入mipmap文件夹中。

如果这时候你去看你的清单文件,就可以看到它的引用ic_launcher:


android:icon="@mipmap/ic_launcher"

如果这时候看看你的mipmap文件夹,你会看到5个不同的普通的启动图标,这些图标将用于低于sdk 26的版本。对于大于等于的sdk 26的,它使用xml文件mipmap-anydpi-v26夹中的文件来使用自适应图标。


<?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>

要添加一个替代API 26+设备上的所有PNG的自适应图标,你将添加一个如下所示的res/mipmap-anydpi-v26/ic_launcher.xml文件:


<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

通过将其放置在mipmap-anydpi-v26文件夹中,资源系统将优先使用其它dpi文件夹中的文件,仅仅在API 26+设备上才会使用。

总结

以上所述是小编给大家介绍的Android Studio 3.0中mipmap-anydpi-v26是什么网站的支持!

来源:http://www.jianshu.com/p/a361e9f5d44c

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com