Android自适应启动图标 说明 指南 手册

Android自适应启动图标 说明 指南 手册

自适应图标出现的目的

  • google为了增加应用启动图标的动画效果

自适应图标资源的构成

  • foreground 应用的图标,由开发者提供
  • background 放在应用图标下面的图片,由开发者提供
  • mask 用来创建动画效果的遮罩图,由厂商提供

让应用具有自适应图标的方法

  • 在res/mipmap-anydpi-v26提供
    • ic_launcher.xml
    • ic_launcher_round.xml
  • 配置manifest/application
    <application
        …
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        …>
    </application>
    
  • 备注
    • ic_launcher.xml例子
    <?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="@drawable/ic_launcher_foreground" />
    </adaptive-icon>
    
    • ic_launcher_round.xml同样定义了background, foreground
    • 资源名字可以自定义,和application里面配置的一致即可

让人困惑的地方

  • 这要从android aip 25的适配说起
    • api 25之前,开发者只需要提供icon
    • 从api 25开始,google要求开发者提供
      • icon
      • roundIcon
  • 自适配图标是不要求一定要提供roundIcon的
  • 自适配图标只要求开发者提供
    • ic_launcher.xml,这个xml文件定义了
      • foreground
      • background

创建自适应图标资源的便捷工具

小结

  • adaptive-icon 给应用启动图标增加动画效果,其资源放在res/mipmap-anydpi-v26文件夹下
  • 常规的 xxx.png 图标提供静态启动图标,无法提供动画效果
  • application的iconRound配置用来适配 android api 25以上的机型
  • 如果想适配 >= android api 25的机型需要
    • 提供
      • icon
      • roundIcon
  • 如果想给启动图标加动画效果,在res/mipmap-anydpi-v26下提供
    • icon的adaptive-icon资源
    • roundIcon的adaptive-icon资源
  • 如果想让提供的资源起效果,配置manifest文件里面的application标签

参考

图例

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值