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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With