0

I have a dimens file that has values that will be used for dp >= 615dp (h615dp)

I am testing the following device:

2055px of height  
screen density: xxhdpi
Dp = 2055/(480/160) = 685 dp

According to this answer: https://stackoverflow.com/a/43749616/20018861 , I have seen that the real screen height pixels are a little less that the pixels of the device, so I have used the following to see the real height's pixels of the device:

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int height = displayMetrics.heightPixels;
    Log.d("height", "height: " + height);

The real height's pixels are: 1911px

Now I am calculating the real dp:

1911px of height  
screen density: xxhdpi
Dp = 1911/(480/160) = 637 dp

Even having calculated the real value, we can see that it is still greater than 615dp

The problem is that even 637 > 615 , the values are not taken from the (h615dp) file and they are taken from the default file...

sacacorchos
  • 163
  • 9
  • 1
    What does [Configuration#screenHeightDp](https://developer.android.com/reference/android/content/res/Configuration#screenHeightDp) display? – Cheticamp Dec 26 '22 at 16:30
  • @Cheticamp it is 613dp, I think that the problem is that DisplayMetrics returns the whole screen height and Configuration returns the used height , I should use Configuration then, right? – sacacorchos Dec 26 '22 at 20:04
  • I think so. Try h613dp and h614dp for the resource qualifiers to see if it behaves accordingly. – Cheticamp Dec 26 '22 at 22:04
  • @Cheticamp yes it is working using the `Configuration#screenHeightDp` dp value. The conclusion of this is that qualifiers use usable screen and not the whole screen. Good to notice that, thanks. – sacacorchos Dec 26 '22 at 22:41

0 Answers0