Search code examples
androidlayouttabletandroid-resources

Android - Resource Configurations Not Working


I am currently trying to update my layout for multiple screen sizes. I am attempting to set the left margin of a button. I have the button set to the proper @dimens resource. When I change the value in the values/dimens.xml the button margin changes.

However, when loading the nexus 9 in the emulator or genymotion emulator they will NOT use the values-sw720dp version of the dimension.

My values folder

values/
    values-sw720dp/
        dimens.xml
attrs.xml
colors.xml
dimens.xml
etc..

I can not figure out why it will not read these values. I am testing it on 5.0 lolipop, and the min android level is 13.

I have double checked the resource is named correctly.

Anyone have any idea?


Solution

  • The values-sw720dp/ folder should be at the same level as the values/ folder, not below it. Your folder hierarchy should look like this:

    res/
        values/
            attrs.xml
            colors.xml
            dimens.xml
        values-sw720dp/
            dimens.xml
    

    Also, make sure that the emulator is matching the -sw720dp resource qualifier. You can check this by putting a string (or something else easily recognizable) with a different value in each resource folder, and print it as a diagnostic.