Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert mm to pixels

Tags:

android

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

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

And no, I don't want to use android:minHeight in xml, this should be in the code.

like image 429
Martin Avatar asked Dec 28 '11 14:12

Martin


1 Answers

Convert 1mm to pixel

float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 1, 
                getResources().getDisplayMetrics());
like image 100
Sunil Kumar Sahoo Avatar answered Oct 06 '22 16:10

Sunil Kumar Sahoo