The error message returned when setting wrap_content in RelativeLayout is invalid,
Respect labor results, reprinted please indicate the source: http://www.cnblogs.com/tangZH/p/8419053.html
During the project, I encountered a strange phenomenon. I set the width of RelativeLayout to wrap_content, and the components in RelativeLayout also set a fixed size, however, the RelativeLayout width is still full throughout the screen.
Why ??? Face-to-face
Baidu later found that the official documentation has explained:
A Layout where the positions of the children can be described in relation to each other or to the parent.Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. for example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT and a child set to ALIGN_PARENT_BOTTOM.
It means:Circular dependency cannot exist between the RelativeLayout size and the sub-level location. For example, you cannot set the RelativeLayout height to WRAP_CONTENT, and set the child to ALIGN_PARENT_BOTTOM.
The two situations I have encountered are as follows:
1. Set the RelativeLayout width to wrap_content, and the child component
Android: layout_alignParentEnd = "true"
As a result, the screen is filled with RelativeLayout width.
2. Set the height of RelativeLayout to wrap_content, and the child component
ALIGN_PARENT_BOTTOM
As a result, the screen is filled with RelativeLayout height.
Finally, I changed my mind to LinearLayout layout.