Android layout--The difference between Android fill_parent, wrap_content and match_parent

Excerpted from: http://www.cnblogs.com/nikyxxx/archive/2012/06/15/2551390.html

 

All three properties are used to accommodate the horizontal or vertical size of the view. A layout based on the content or size of the view is more convenient than specifying the exact extent of the view.

1)fill_parent

Setting a widget's layout to fill_parent will force the widget to expand to fill as much space as possible within the layout cell. This is roughly the same as the dockstyle property of Windows controls. Setting a top layout or control to fill_parent will force it to fill the entire screen.

2) wrap_content

Setting a view's size to wrap_content will force the view to expand to display the full content. Take TextView and ImageView controls as an example, setting wrap_content will display the text and images inside them completely. Layout elements will change size according to the content. Setting a view's size to wrap_content is roughly equivalent to setting the Windows control's Autosize property to True.

3) match_parent
   In Android2.2, match_parent and fill_parent have the same meaning. The two parameters have the same meaning, and match_parent is more appropriate, so both words can be used from 2.2. Then if you consider the use of lower versions, you need to use fill_parent

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326115913&siteId=291194637
Recommended