Abhishek Bansal
Abhishek Bansal

Reputation: 5335

How to provide dimens values for xhdpi and above?

Is it possible to give one set of dimen values for xhdpi and above densities and another set of dimen values for hdpi and below densities in android? I have been trying to accomplish this by creating one values-xhdpi folder for xhdpi and above densities and keeping values folder for other densities.

Is this approach correct, because I am not getting expected results. If no then what is the right approach to accomplish this?

Upvotes: 0

Views: 150

Answers (1)

Denysole
Denysole

Reputation: 4051

Yes, your approach is partially correct according to https://developer.android.com/guide/practices/screens_support.html#support

If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density

That means if you will have for example xxhdpi screen, system will pick resources from xhdpi folder.

But if you want to use hdpi resources for all the below density screens, you should provide values-hdpi rather than just values.

You can find this quote in the documentation:

The system assumes that default resources (those from a directory without configuration qualifiers) are designed for the baseline screen density (mdpi), unless they are loaded from a density-specific resource directory.

So there is no guaranty that system will pick your resources from values folder for hdpi screen.

Upvotes: 1

Related Questions