温故而知新。
They're the same thing (in API Level 8+). Use match_parent
.
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
.
其实很简单,fill_parent在API 8以上就被谷歌弃用了,改名为match_parent。
如果要问为什么,再看:
Google changed the name to avoid confusion.
Problem with the old name fill parent
was that it implies its affecting the dimensions of the parent, while match parent
better describes the resulting behavior - match the dimension with the parent.
Both constants resolve to -1
in the end, and so result in the identical behavior in the app. Ironically enough, this name change made to clarify things seems to have added confusion rather than eliminating it.
(有点讽刺的是,修改名称好像增加了混乱 哈哈)