Android 为什么要用 match_parent 替换掉 fill_parent

2019-8-26 liuyingcong 安卓开发

官方的解释是:

Note: Beginning with Android 2.2 (API level 8), "fill_parent" has been renamed "match_parent" to better reflect the behavior. The reason is that if you set a view to "fill_parent" it does not expand to fill the remaining space after sibling views are considered, but instead expands to match the size of the parent view no matter what—it will overlap any sibling views.

意思是:

当一个 View 有兄弟 View 的时候,fill_parent 给人的感觉像是:填充兄弟 View 剩余的部分。

但是,它的实际效果是:铺满父窗体,遮盖这些兄弟 View。所以改用 match_parent 更贴切。

网站备案号:京ICP备11043289号-1 北京市公安局网络备案 海1101084571
版权所有 北京育灵童科技发展有限公司 Copyright © 2002-2024 www.elight.cn, All Rights Reserved