Convert mm to pixels

Does anyone have a good algorithm for converting mm to pixels on Android?

The thing is, I want to be able to set the minimum height of the view using mm as a unit.

And no, I do not want to use android: minHeight in xml, it should be in the code.

+5
source share
1 answer

Convert 1 mm to pixel

float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 1, 
                getResources().getDisplayMetrics());
+15
source

All Articles