Search code examples
androidassets

Multiple assets file for Different Screen Resolutions


I want to create an xml file containing some configurations and this configurations is varied in multiple screen resolutions.

Because I want to define different configurations for different screen resolutions I define assets folder and assets-sw600dp folder and create different xml configurations in each one.

But it doesn't worked.

It seems that this trick can not be applied to assets folder, if so please somebody explain how can I create multiple configurations for different screen resolutions?

Thanks.


Solution

  • You can't create resource qualifiers for assets folder (which is intended to get access to original file names and file hierarchy), you can use /res/raw resource folder instead.

    For XML you also can use /res/xml resource folder.

    More info: https://developer.android.com/guide/topics/resources/providing-resources.html

    P.S. If you need assets folder for some reason you have to make your own implementation for resource switching within assets directory. For example, /assets/phone/somefile and /assets/tablet/somefile.