What is Wrap_Content and Match_Parent in Android Studio

In Android development, there are two common ways to define width and height. They are wrap_content and match_parent. But how do we know when to use the two of them. Let’s take a closer look.


The wrap_content, as the name suggests, it wraps the content based on the content or the values of the element. For example, a textview has a text value of “This is a text”. The width of the textview will depend on the text that you entered. As a result, the width of the textview will match the content it has and it won’t occupy more spaces than expected.


The match_parent, as the name suggests, it matches the parent’s size. For example, the width or the height of the parent. It is used to create an element that matches the size of the parent’s width or height. If you want to have an image that extends from the entire width or height of the screen, you can use match_parent to achieve it.

In the image below, you can visualize the difference of wrap_content from match_parent.

image description

I hope this helped, thank you!

Leave a Comment

Your email address will not be published. Required fields are marked *