A new Android developer may get confused about what's the difference between fill_parent, match_parent, and wrap_content.
What are they ?
These three are called as Layout Parameters. They are used by sub-views to tell the parent view how they want to be laid on the Activity screen i.e we can set the Horizontal and Vertical size of a view using Layout Parameters.
To specify how big a view must be we use android:layout_width and android:layout_height attributes.
The values of these attributes can either one of fill_parent, match_parent or wrap_content.
1. match_parent
When you set layout width and height as match_parent, it will occupy the complete area that the parent view has, i.e. it will be as big as the parent.
Note: If a parent has applied to padding then that space would not be included.
When we create a layout.xml by default we have RelativeLayout as default parent View with android:layout_width="match_parent" and android:layout_height="match_parent" i.e it occupies the complete width and height of the mobile screen.
Also note that padding is applied to all sides,
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
Now lets add a sub-view LinearLayout and sets its layout_width="match_parent" and layout_height="match_parent", the graphical view would display something like this,

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.code2care.android.togglebuttonexample.MainActivity" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:background="#FFFFEE"
android:orientation="vertical" >
2. fill_parent :
This is the same as match_parent, fill_parent was deprecated in API level 8. So if you are using API level 8 or above you must avoid using fill_parent
Let's follow the same steps as we did for match_parent, just instead use fill_parent everywhere.
You would see that there is no difference in behavior in both fill_parent and match parent.
3. wrap_content
If you set layout width or height as wrap_content it will use space big enough for its contents to get enclosed.
Let's create a new activity.xml file, with RelativeLayout parent View, now let's add a LinearLayout and set,
android:layout_width="wrap_content"
android:layout_height="wrap_content"

You would see that the sub-view LinearLayout does not occupy any space as there is nothing that it holds that has to be displayed.
Let's add a Button to the LinearLayout with width and height as "wrap_content". You would see that now the LinearLayout occupies space as that required by the button to be displayed.
Code :
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.code2care.android.togglebuttonexample.MainActivity" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:background="#FFFFEE"
android:orientation="vertical" >
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
Conclusion
fill_parent, and match_parent are the same, used when we want the height or width of a view to being as big as its parent view, fill_parent being deprecated.

wrap_content is used when we want the view to occupy only as much space as required by it.
- Android Error Unexpected cast to Button: layout tag was FrameLayout
- ADT quit unexpectedly error on Mac OSX Android Eclipse SDK
- Parsing Data for android-21 failed unsupported major.minor version 51.0
- Android Studio Ctrl Shift o auto import not working
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android : How to make TextView Scrollable
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error
- Integrating Android Facebook SDK 3.17.2 Tutorial
- Android R Cannot Be Resolved To A Variable
- Android : Exception raised during rendering: action_bar API 22
- How to take screenshot on Android
- Read Text file from SD Card : Android Programming
- How to make Android EditText not editable
- Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later.
- The declared package does not match the expected package Eclipse
- Can't Run SDK Manager find_java.bat issue
- What is Android Toast.LENGTH_SHORT and Toast. LENGTH_LONG durations
- Android Emulator Soft Back button action using Computer keyboard
- Multiline EditText in Android Example
- Use 5G Network on Android Emulator
- Make Android TextView Clickable like Buttons
- How to empty trash in Android Device
- Android : Execute some code after back button is pressed
- Disable Fading Edges Scroll Effect Android Views
- How To Disable Landscape Mode in Android Application
- How to Change Eclipse Default Web Browser - Eclipse
- How to install tabnine on VS Code - HowTos
- How to Center Align Image in Bootstrap - CSS
- Connection Failed: 1130 PHP MySQL Error - MySQL
- Java SE 8 Update 301 available with various bug fixes and security improvements - Java
- Microsoft Teams Error code - 6 issue - Teams
- 11 Weeks of Android Online Sessions-15-Jun-to-28-Aug-2020 - Android
- Increase Android Emulator Timeout time - Android