开发者

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

开发者 https://www.devze.com 2023-04-05 00:44 出处:网络
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.

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 minW开发者_开发知识库idth) 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消