Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android customize drawable folder to subfolder

Sub-Folder I didn't mean the drawable-hdpi, drawable-mdpi, drawable-ldpi, etc but @drawable\myfolder\img.png

I'm a bit concerned on customizing the folder structure in drawable similar the way we have package to structure the java files.I'm using too many images for my project and when I try to copy activity layout xml; searching for the images in drawable, I felt it boring! Does android have such feature or some wayout?

like image 606
A_rmas Avatar asked Mar 23 '16 11:03

A_rmas


2 Answers

I think, currently this way exists. I also have many drawables and layouts, so tried to start from layouts and then added drawables and menus. I recommend to see Can the Android Layout folder contain subfolders? and http://alexzh.com/tutorials/how-to-store-layouts-in-different-folders-in-android-project/.

Yes, I have now new resources in new subfolders. It requires time to manage (create res folders, edit build.gradle), but a folder tree becomes more neat. Sometimes AS cannot find resources during compilation. In this case I have to create new folders and edit build.gradle. Probably after several weeks everything will be done.

UPDATE

It has worked until Android Studio updated to 3.2 (and 3.2.1). Currently if you move any drawable, layout, menu resource to another folder (and add this folder to build.gradle as written in the articles above) you cannot normally use it. Before 3.2 we could simply press Build > Rebuild Project and reference to that resource. Now they have broken this behaviour and you should press File > Invalidate caches / Restart... > Just Restart (or close and open AS) to access this drawable as usual. If you don't want to restart AS, you can use the resource, but write a path to it manually like @drawable/reset_password, AS won't hint as you type and won't draw it in Design tab.

If you use Kotlin Android extensions and reference to ids like send_button (without findViewById()) you will get so many bugs that can't imagine. If you change resources, often nothing changes in layouts until you rebuild the project. This is because Kotlin caches resources. I often forget about it and waste hours.

like image 113
CoolMind Avatar answered Oct 19 '22 23:10

CoolMind


As far as i know, NO. There was an interesting post on G+ with a workaround for the layout dir, that works also for the drawables dir. I guess.

All the infos are here

like image 42
marco Avatar answered Oct 20 '22 01:10

marco