Android fill_parent to match_parent

纵然是瞬间 提交于 2020-01-03 08:14:30

问题


What was the reason behind introducing match_parent and deprecating fill_parent since both mean the same thing. won't this change be a hindrance to backward compatibility?


回答1:


Using match_parent instead of fill_parent will NOT make the generated APK unrunnable in older versions because in the generated APK the occurrence of match_parent's and fill_parent's will be replaced with their corresponding Constant Value, which is same in this case (both are -1), so same APK can run on older versions of Android platform as well.

But while compiling the code if you switch to older version (version 7 or below) then you will get a compilation error (since match_parent is not defined in version 7 or below).




回答2:


Android Doc says:

FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding)

fill_parent: 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.

So They are the same as their values are both -1. But if you worry about the backward compatibility, you can go here: platfrom version

this give you a better idea on when you should change all your fill_parent to match_parent. as of now, it seems 50% ppl are using API Level 8 or above. So it's up to you to change it.



来源:https://stackoverflow.com/questions/7608196/android-fill-parent-to-match-parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!