Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What unit of measurement does setMinimumWidth() use in an android view?

I understand the difference between the various measurement units used in android layouts (dp, sp, px, etc), but it's not clear to me which unit is used when setting the width via java code.

Which unit does setMinimumWidth(int minWidth) use?

like image 920
Jimtronic Avatar asked Sep 15 '11 22:09

Jimtronic


1 Answers

Pixels. All values set by code are in pixels. If you want different values, you must compute pixels using getResources().getDisplayMetrics().density to do conversion (or using other values from DisplayMetrics).

like image 145
Pointer Null Avatar answered Nov 13 '22 15:11

Pointer Null