布局文件中fill_parent和match_parent有什么区别?



1)fill_parent设置一个构件的布局为fill_parent将强制性地使构件扩展,以填充布局单元内尽可能多的空间。这跟Windows控件的dockstyle属性大体一致。设置一个顶部布局或控件为fill_parent将强制性让它布满整个屏幕。2)match_parent Android2.2中match_parent和fill_parent是一个意思 .两个参数意思一样,match_parent更贴切,于是从2.2开始两个词都可以用。那么如果考虑低版本的使用情况你就需要用fill_parent了

有网友表示对于很多工程中的MATCH_PARENT出现在layout中感到不明白,过去只有FILL_PARENT和WRAP_CONTENT那么match_parent到底是什么类型呢? 其实从Android 2.2开始FILL_PARENT改名为MATCH_PARENT ,从API Level为8开始我们可以直接用MATCH_PARENT来代替FILL_PARENT,最后Android123提醒大家,他们的定义本质是一样均为-1,只是换了个别名,可能为了更准确些,比如最终在SDK中的定义为:

fill_parent   -1  The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by match_parent.  
match_parent   -1 The view should be as big as its parent (minus padding). Introduced in API Level 8.  
wrap_content   -2  The view should be only big enough to enclose its content (plus padding).  

原文地址:https://www.cnblogs.com/mochaMM/p/5092539.html