drorsun
drorsun

Reputation: 891

Android debug - how to know what resource file is used?

I am working on a mature app, trying to add specific dimension setting for the Google-Pixel phone.

AFAIU for Pixel I should put the specific value I need inside values-xxhdpi/dimens.xml. I created that path and file and placed the value including a qualifier tag - like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="qualifier">xxhdpi</string>

    <dimen name="my_value">48dp</dimen>

</resources>

I tried without the qualifier as well and also placing it in values-xxxhdpi.

The problem is that it doesn't catch and I suspect some other values-??? folder is catching somehow. There are quite a few of those so I am not sure which one.

Is there a way in debug time to know the exact resource file name/path being used?

Upvotes: 2

Views: 1153

Answers (1)

Ameer
Ameer

Reputation: 2769

You can check the density in your code.

    switch (getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
    // handle your code here for ldpi
    break;
case DisplayMetrics.DENSITY_MEDIUM:
    // handle your code here for mdpi
    break;
case DisplayMetrics.DENSITY_HIGH:
   // handle your code here for hdpi
    break;
case DisplayMetrics.DENSITY_XHIGH:
    // handle your code here for xhdpi
    break;
}

and Place a log and check which one is using

Upvotes: 2

Related Questions