Like you, I’ve probably wasted many hours slowly importing drawables one by one into Android Studio. mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, one drag and drop for each. For me, it actually started with Eclipse, where dragging and dropping every size of an image one by one was only one of the many dreadful thing that was required to make an Android app. For the years to follow, Android Studio didn’t remedie this. My flow was faster, yet adding image was the same old tedious process. Some extensions tried to help with that, but none I found did the job well. Recently, the Android Studio team turned things around.
Resource Manager and bulk importing PNGs
I’ve been using Android Studio’s new Resource Manager for a couple months now and I have to say that is is game changer. Resource Manager navigates your sub-folders and imports the right assets for each screen density. It saves a lot of time. I’m actually so happy with it that I thought it’d be worth sharing my current workflow to import PNG assets.
To get started, you need some assets to import. In our case, we have a star icon freshly exported from Sketch.
./exports/ ./exports/hdpi ./exports/hdpi/ic_star ./exports/mdpi ./exports/mdpi/ic_star ./exports/xhdpi ./exports/xhdpi/ic_star ./exports/xxhdpi ./exports/xxhdpi/ic_star ./exports/xxxhdpi ./exports/xxxhdpi/ic_star
That’d be quite a few steps to bring each icon in the right folder. Ideally, we’d select
exports and call it a day. So let’s do just that.
Open to View > Tool Windows > Resource Manager
On the top left, click on + then Import Drawables
Now you want to select the parent of all your resource folders. In this case, we want to make sure to select
exports and none of the sub folders.
You will be prompted with an import window. From there, you can just click import and all your assets will be updated.
And you’re done! This is just as fast with one asset as it is with many. Even better, Resource Manager is smart enough not to import the assets you already have. You can actually use a single export folder from your harddrive, dropbox, google drive or other, and import it over and over- Resource Manager will take what it needs and leave the rest. It makes collaboration with a designer easier, and helps you keep your assets organized if you’re doing exports yourself.
2019-06-27 18:34 +0000