关于Android Studio Image Asset 选项,设置app icon

2021/5/19 10:27:39

本文主要是介绍关于Android Studio Image Asset 选项,设置app icon,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

在Android Studio,通过 Image Asset 选项可以设置ic_launcher. 今天用了之后发现低等级的API并不能正确设置 app icon。阅读文档发现 adaptive icon的概念在8.0被提出。


附上原文。
Android 8.0 (API level 26) introduces adaptive launcher icons, which can display a variety of shapes across different device models. For example, an adaptive launcher icon can display a circular shape on one OEM device, and display a squircle on another device. Each device OEM provides a mask, which the system then uses to render all adaptive icons with the same shape. Adaptive launcher icons are also used in shortcuts, the Settings app, sharing dialogs, and the overview screen.

You can control the look of your adaptive launcher icon by defining 2 layers, consisting of a background and a foreground. You must provide icon layers as drawables without masks or background shadows around the outline of the icon.


文中提到新的定义中App icon有两层,例如底层设置一层底色,上层设置一个图标,这样不同的设备可以根据需要裁剪成需要的形状不管是方形或是圆形,我们常见不同规格的图标。

在另外一个链接有如下信息。
 A legacy launcher icon is a graphic that represents your app on a device's home screen and in the launcher window. Legacy launcher icons are intended for use on devices running Android 7.1 (API level 25) or lower, which don't support adaptive icons, and don't display as varying shapes across device models.


adaptive icons 只能用于API>=26。他提供了一个xml file res/mipmap-anydpi-v26/ic_launcher.xml
如果要用传统的方式只需按照以前的方法在 res/mipmap-density/ 的文件夹中添加 ic_launcher.png

这样manifest中的ic_launcher就有了不同的解读方法对于 API >=26 到 ic_launcher.xml取 其他的到mipmap中寻找需要分辨率的png


原文地址
https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive
https://developer.android.com/studio/write/image-asset-studio



这篇关于关于Android Studio Image Asset 选项,设置app icon的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程