Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is negative value for width or height?

Tags:

android

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

like image 728
sandalone Avatar asked Oct 10 '22 15:10

sandalone


1 Answers

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.

like image 172
theisenp Avatar answered Oct 14 '22 01:10

theisenp