What is the difference between match
I'm a little confused about two XML properties: match_parent
and fill_parent
. It seems that both are the same. Is there any difference between them?
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
.
http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html
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.
Functionally no difference, Google just changed the name from fill_parent to match_parent, from API level 8 (Android 2.2). FILL_PARENT is still available for compatibility reason.
LayoutParams.FILL_PARENT
and LayoutParams.MATCH_PARENT
both have value -1. Not sure what tempted google to change from Fill Parent to Match Parent :)
Since most of the phones are >= Android 2.2
.. you should use Match Parent for future compatibility... not sure when they will discontinue the older Fill Parent constant!
上一篇: Android权限:我怎样才能知道哪些是比正常危险?
下一篇: 比赛有什么区别