1

During my research on what's the difference between match_parent and fill_parent, I found that at the time of API 8 epoch Google just 'renamed' fill_parent to match_parent since the latter better describes the effect and made fill_parent deprecated.

What is silly to me, being official and solid IDE at least in code inspection part, after so many years Android Studio 2.3.3 still doesn't highlight usages of fill_parent as deprecated and not asking to change it to match_parent. It doesn't strike fill_parent through in suggestion lists also.

So the question is should we ALWAYS use match_parent instead of fill_parent in new code or using them interchangeably is kind of established practice in Android development and this is the reason why Android Studio doesn't warn us about the deprecation of fill_parent?

Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
  • 1
    "The question is why after so many years Android Studio 2.3.3 still doesn't highlight usages of fill_parent as deprecated and not asking to change it to match_parent?" -- questions of the form "why did Developer X make Decision Y?" are unsuitable for Stack Overflow. The only one who can answer the question definitively is Developer X, who is unlikely to see this question. Anyone else can only offer opinions. – CommonsWare Jul 10 '17 at 22:12
  • @CommonsWare: You're right. I've made edits in attempt to pose a question more clearly. – Alexander Abakumov Jul 10 '17 at 22:31
  • THey're the same thing, they just renamed it. Frankly I wouldn't care about it- they're not going to remove it because it isn't worth the cost, and if they do, a 10 second control-R will fix it. On the top thousand things to worry about when coding Android list, this rates around 995. – Gabe Sechan Jul 10 '17 at 23:45

1 Answers1

3

https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#FILL_PARENT

In the documentation, you can see that FILL_PARENT and MATCH_PARENT have the same value (-1) so it is the same thing only with a different name.

In this post http://www.randomlytyping.com/blog/2014/2/9/matchparent-vs-fillparent it's explained a lot like:

So why was MATCH_PARENT added?

The Android team found that developers were misinterpreting FILL_PARENT to mean that a View would fill the remaining space left in its parent. In fact, by specifying FILL_PARENT, the View is requesting to be as big as its parent.

Okay, I get how FILL_PARENT/MATCH_PARENT works. What does it matter if I use one or the other?

FILL_PARENT is deprecated. Being deprecated does not make it the Devil, but eventually it will go away. Your application is more future-proof using MATCH_PARENT. Why use the deprecated option when the current option behaves exactly the same?

Community
  • 1
  • 1
yasin
  • 1,297
  • 3
  • 17
  • 36