Issue
I'm working on an application that deals with getting an image from the drawable folder. In one of my last application what I did was I created a different ic_abc folders for each icon in my application and in there, there would be same image with different sizes in each of them. I was using these icons in the menu folder in that application.
Now in this application I don't know why but I can't access my drawable assets directly from the activity like R.id.imagename or R.drawable.imagename
Any ideas why is it acting like this?
Solution
The resource system currently does not support sub folders in your drawable folders. However, the different sizes of icons will be automatically arranged in appropriate subfolders by Android Studio if you do it properly.
You will need the following setup:
res
-- drawable
-- drawable-mdpi
-- drawable-hdpi
-- drawable-xhdpi
etc..
Then when you put your icon sizes in each of these folders, Android Studio will map them under one folder that has the same name as your icon.
The reason why you can't reference the files in your subfolders trough the R file is because the compiler will ignore any files in a subfolder, therefor it doesn't add the reference to the R.java file.
Answered By - Tim Kranen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.