What is the best way to get a screens dp pixel hei...
# android
d
What is the best way to get a screens dp pixel height programmatically? I tried using
context.display?.getRealMetrics(displayMetrics)
but that seems to return a much larger value than I'm looking for. I know for Pixel 2 the height is ~730, but I get 1920 when using
displayMetrics.heightPixels
. In other words, I'd like to see programmatically which devices will use
values
and which will use
values-h700dp
😶 4
update: figured this one out, the answer is
Copy code
val height = resources.configuration.screenHeightDp