Android vector drawable for launcher icon and other images on Android N

与世无争的帅哥 提交于 2019-12-02 20:35:33

Vector drawable is not supported for launcher icons. You are, however, encouraged to use it everywhere else.

mixel

You can use vector drawables as launcher icon if you follow these steps:

  1. Place vector launcher icon under drawable directory. You can't place vector drawables in mipmap directory because they will work only in API levels 21 and above. As you possible know it's recommended to place PNG launcher icons under mipmap-<density> directories instead of drawable-<density> ones, and this matters because if you have a split apk build or use the new aab format to upload your app ("Google Dynamic Delivery"), both processes will remove all drawable-<density> directories except the one for the current density.

  2. Remove vectorDrawables.useSupportLibrary = true in build.gradle defaultConfig section if you set it earlier. This will enable build-time PNG generation for vector drawables for API levels lower then 21. If you do not remove this option than android:icon attribute of the <application> tag will load default Android "green robot" icon.

I tested it on API level 16 device and it works perfectly.

It seems vector drawables are now supported for launcher icons. I have recently uploaded and published an app (to alpha) with a vector drawable as a laucher icon.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!