简体   繁体   中英

ic_launcher Icon size in Android Studio

I replaced the default ic_launcher icon to another image, but I have a problem with the size of the icon and I cannot get the full size as shown in the bellow image.

在此处输入图片说明

Could anyone help me and tell me how to make the icon full size?

any help is appreciated??

File -> New -> Image Asset

Select Launcher icons as asset type

choose high res image

and dont forget to tick the box that says "Trim surrounding blank space"

credits : this question

I found two solutions to get around the extra padding that Android Studio adds when creating icons:

  1. Resize images using a [Windows] batch file. This is the one I use because it's the easiest for me (on Windows):

    a. Create a ResizeImage.exe using the simple code from http://www.ianmcintyre.com/2014/06/c-resize-image-fit-image.html

    b. Save the following ResizeAndroidLauncherImage.bat file in the same directory as ResizeImage.exe. This copies your original image to the various directories and resizes them:

     @echo off setlocal set subdir=%2 set iconsize=512 if not exist "%subdir%" mkdir "%subdir%" copy /Y %1 %subdir%\\ic_launcher-web.png %~dp0ResizeImage.exe %subdir%\\ic_launcher-web.png %iconsize% %iconsize% set subdir=%2\\res\\mipmap-xxxhdpi set iconsize=192 if not exist "%subdir%" mkdir "%subdir%" copy /Y %1 %subdir%\\ic_launcher.png %~dp0ResizeImage.exe %subdir%\\ic_launcher.png %iconsize% %iconsize% set subdir=%2\\res\\mipmap-xxhdpi set iconsize=144 if not exist "%subdir%" mkdir "%subdir%" copy /Y %1 %subdir%\\ic_launcher.png %~dp0ResizeImage.exe %subdir%\\ic_launcher.png %iconsize% %iconsize% set subdir=%2\\res\\mipmap-xhdpi set iconsize=96 if not exist "%subdir%" mkdir "%subdir%" copy /Y %1 %subdir%\\ic_launcher.png %~dp0ResizeImage.exe %subdir%\\ic_launcher.png %iconsize% %iconsize% set subdir=%2\\res\\mipmap-hdpi set iconsize=72 if not exist "%subdir%" mkdir "%subdir%" copy /Y %1 %subdir%\\ic_launcher.png %~dp0ResizeImage.exe %subdir%\\ic_launcher.png %iconsize% %iconsize% set subdir=%2\\res\\mipmap-mdpi set iconsize=48 if not exist "%subdir%" mkdir "%subdir%" copy /Y %1 %subdir%\\ic_launcher.png %~dp0ResizeImage.exe %subdir%\\ic_launcher.png %iconsize% %iconsize% endlocal 

    c. Execute the batch file every time you update your icon:

     ResizeAndroidLauncherImage.bat [YourIcon.png] [YourAndreoidSRCDir] 
  2. Use the Android Asset Studio ( https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html ). You'll have to modify the source to remove the extra padding. See https://github.com/romannurik/AndroidAssetStudio/issues/73 for a discussion on how to do that. I tried this and used "none":

     const TARGET_RECTS_BY_SHAPE = { none: { x: 0, y: 0, w: 46, h: 46 }, circle: { x: 2, y: 2, w: 44, h: 44 }, square: { x: 5, y: 5, w: 38, h: 38 }, vrect: { x: 8, y: 2, w: 32, h: 44 }, hrect: { x: 2, y: 8, w: 44, h: 32 }, }; 

If I had Photoshop on my development machine, I would also try:

  1. Record and play back a batch script in Photoshop. [Note that I did not try this]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM