Differences between Android fill_parent, wrap_content, and match_parent

Source: Internet
Author: User

The three attributes are used to adapt to the horizontal or vertical size of the view. A Layout Based on The View content or size is more convenient than specifying the view range accurately.

1) fill_parent

Setting the layout of a component to fill_parent will forcibly extend the component to fill as much space as possible in the layout unit. This is basically the same as the dockstyle attribute of the Windows Control. Setting a top layout or control to fill_parent will forcibly overwrite the entire screen.

2) wrap_content

Setting the size of a view to wrap_content will forcibly extend the view to display all the content. The textview and imageview controls are used as examples to set wrap_content to completely display the internal text and images. The layout element is changed based on the content. Setting the size of a view to wrap_content is basically equivalent to setting the autosize attribute of a Windows Control to true.

3) match_parent
In android2.2, match_parent and fill_parent are the same. The two parameters have the same meaning. match_parent is more appropriate, so both words can be used from 2.2. If you want to use a lower version, you need to use fill_parent.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.