Reputation: 16761
So, I'm making an app that has many different res folders for values, drawables and layouts. The variation is by screen size, mobile country code (I'm using this field to override it and thus enable different skins in my app, much like iOS targets), landscape / portrait, screen widths, languages & dpi.
One of my biggest problems for this app is the fact that I need to support both tablets & phones. I create a layout for phones under layout-normal. If I do this, it seems like I must copy-paste my tablet layout into both the layout-large & layout-xlarge folders. If I don't, the app defaults to the normal layout.
I was wondering if there was a way in Android to override the way the runtime determines which folder it goes to. This way, I could via code, direct the run-time to the correct folder depending on the device's configuration, and not need to copy-paste my layouts all over the place.
Note:
I specified 1 reason I want to do this, but there are also several others. I'm looking for a way to override the way android determines which res folder it goes to, not a different solution to the 1 problem I specified above.
Any advice would be greatly appreciated!
Upvotes: 1
Views: 288
Reputation: 87064
In order to avoid the duplication you could use the resource alias mechanism as described here. That system can be used for images, layouts and other resources from the values folder.
Upvotes: 2
Reputation: 17284
Selection is done based on device configuration as explained here so if you could find a way to alter device configuration then it will work. But it will effect other apps as well. There are apps that allow you to change your device modes. There are custom ROMS that give this ability e.g. Paranoid ROM
Upvotes: 0