Is deprecated word the only difference between fill_parent and match_parent
As you said they are exact the same. As Romain Guy said, they have changed the name because "fill_parent"
was confusing for developers. As matter of the fact, "fill_parent"
does not fill the remaining space (for that you use the weight attribute) but it takes as much space as its layout parent. That's why the new name is "match_parent"
.
What is the difference between match_parent and fill_parent?
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 bymatch_parent
.
http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html
Is using fill_parent still a proper practice?
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?
difference between fill_parent and match_parent in android
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
For Android API 1.6 to 2.1 match_parent
will throw you an error, so use fill_parent in these cases. To support backward compatibility, it's better to use fill_parent
I remember that Roman Guy (Android Developer at Google) said, that they have changed the name because "fill_parent"
was confusing for developers. As matter of the fact, "fill_parent"
does not fill the remaining space (for that you use the weight attribute) but it takes as much space as its layout parent. That's why the new name is "match_parent"
What's the difference between fill_parent and wrap_content?
Either attribute can be applied to View's (visual control) horizontal or vertical size. It's used to set a View or Layouts size based on either it's contents or the size of it's parent layout rather than explicitly specifying a dimension.
fill_parent
(deprecated and renamed MATCH_PARENT
in API Level 8 and higher)
Setting the layout of a widget to fill_parent will force it to expand to take up as much space as is available within the layout element it's been placed in. It's roughly equivalent of setting the dockstyle of a Windows Form Control to Fill
.
Setting a top level layout or control to fill_parent will force it to take up the whole screen.
wrap_content
Setting a View's size to wrap_content will force it to expand only far enough to contain the values (or child controls) it contains. For controls -- like text boxes (TextView) or images (ImageView) -- this will wrap the text or image being shown. For layout elements it will resize the layout to fit the controls / layouts added as its children.
It's roughly the equivalent of setting a Windows Form Control's Autosize
property to True.
Online Documentation
There's some details in the Android code documentation here.
Related Topics
Failure [Install_Failed_Older_Sdk] Android-L
Mpandroidchart - Adding Labels to Bar Chart
Android: How to Change the Datepicker View Date Format from Mm/Dd/Yyyy to Dd/Mm/Yyyy
Android Sharedpreferences Limitations
Problem Loading Swf File in Android
How to Get a Fragment to Remove Itself, I.E. Its Equivalent of Finish()
Android Design Considerations: Asynctask VS Service (Intentservice)
Android Cursor with Ormlite to Use in Cursoradapter
Otp (Token) Should Be Automatically Read from the Message
Android Marshmallow: Test Permissions with Espresso
Android Studio Where to Install Ndk File? (Downloaded It in Zip)
How to Stop/Cancel Android Countdowntimer
Scrolling Edittext Inside Scrollview
Does the Android Emulator Support Opengl Es 3.0
Getting Null Device Id While Registering to Gcm
Should Accessing Sharedpreferences Be Done Off the UI Thread