Load dimension value from res/values/dimension.xml from source code

I’d like to load the value as it is. I have two dimension.xml files, one in /res/values/dimension.xml and the other one in /res/values-sw360dp/dimension.xml. From source code I’d like to do something like getResources().getDimension(R.dimen.tutorial_cross_marginTop); This works but the value I get is multiplied times the screen density factor (1.5 for hdpi, 2.0 for xhdpi, etc). I … Read more

getting the screen density programmatically in android?

How to get the screen density programmatically in android? I mean: How to find the screen dpi of the current device? 19 s 19 You can get info on the display from the DisplayMetrics struct: DisplayMetrics metrics = getResources().getDisplayMetrics(); Though Android doesn’t use a direct pixel mapping, it uses a handful of quantized Density Independent … Read more