Creating a new Icon Set in Android Studio?

前端 未结 3 698
感动是毒
感动是毒 2021-01-07 17:23

In Eclipse there is File|New|Android Icon Set... How do I do the same in the Android Studio?

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 18:11

    I use an additional module in my Android Studio Projects to let Gradle generate the icon resources. To create icons, I use Inkscape. Setup: You have just to add an new module 'icons' to your Android Studio project, taken from GitHub. Then, define once the icons sizes in the my.properties file for mdpi:

    // All icon heights in dpi for drawable-mdpi
    actionbarIcon=32
    notificationIcon=30
    launcherIcon=40
    iconSmall=25
    iconMid=35
    iconBig=45
    

    For every new icon, add a property line to the config file 'icon.properties':

    // Icon with suffix         | SVG file with suffix      |size property          |module |flavor
    //--------------------------------------------------------------------------------------------------
    ic_action_export.png        |action_icon_export.svg     |actionbarIcon          |app    |main
    

    That's all. Now you can run the Gradle task :icons:generate. This task updates the resource files for every changed icon:

    app
      - main
        - res
          - drawable-hdpi
            - ic_action_export.png
          - drawable-mdpi
            - ic_action_export.png
          - drawable-xhdpi
            - ic_action_export.png
          - drawable-xxhdpi
            - ic_action_export.png      
          - drawable-xxxhdpi
            - ic_action_export.png  
    

    See my blog for a detailed description.

提交回复
热议问题