开发者

What is negative value for width or height?

开发者 https://www.devze.com 2023-03-16 05:25 出处:网络
What is the purpose of such code: android:layout_开发者_开发技巧height=\"-2\" Or android:layout_width=\"-1\"

What is the purpose of such code:

android:layout_开发者_开发技巧height="-2"

Or

android:layout_width="-1"

How should I interpret such values? Are they in connection to layout_weight attribute?

Thanks


EDIT: My mistake, I misunderstood the question.

The negative values seem to represent match_parent, wrap_content, and fill_parent.

When -1 or -2 is applied, the view fills the screen just as it would for match_parent or fill_parent. When any number -3 or lower is applied, the behavior is the same as wrap_content.

The values are not related to the layout_weight, just the pre-defined constants for width and height in Android.

0

精彩评论

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