October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Mountain View desk2 min

Wrap_content vs. Match_parent: How Android View Sizing Works

Android’s wrap_content fits a view to its content; match_parent requests the space its parent allows. Learn how to choose each dimension and account for parent-layout behavior.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

wrap_content sizes a view to fit its content and its own padding; match_parent asks for the space available from its immediate parent, after the parent’s padding is accounted for. Set width and height independently. The right choice depends on the space the view should occupy and on how its parent measures children.

What each value means

Value What it requests Use it when
wrap_content Enough space to enclose the view’s content, including the view’s own padding. The view should size to its text, drawable, or other internal content.
match_parent The size available from the parent, minus the parent’s padding. The view should occupy the available space in that dimension.

Android’s ViewGroup.LayoutParams reference describes match_parent as: “The view should be as big as its parent (minus padding).” This is a request interpreted through the parent layout’s measurement rules, not a guarantee that the child will fill the physical screen.

As an Amazon Associate I earn from qualifying purchases.

How to choose width and height

The two values are independent. Android’s layout resource documentation allows each of android:layout_width and android:layout_height to use a dimension, match_parent, or wrap_content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Choose wrap_content for a dimension that should follow the content, such as a button whose width follows its label.
  • Choose match_parent when the view should use the parent’s available width or height.
  • Mix them when appropriate: a view can use match_parent for width and wrap_content for height, or the reverse.

For example, a label might need content-sized height while spanning the width available from its parent. The choice for one dimension does not dictate the choice for the other.

Why the parent layout matters

A view does not size itself in isolation. The immediate parent measures and constrains its child, so the result depends on both the requested value and the parent’s rules. In particular, match_parent means the parent’s available size—not automatically the device’s full screen.

ConstraintLayout

In ConstraintLayout, 0dp means “match constraints”: the view uses the space available within its constraints. Android’s responsive and adaptive design guidance presents wrap_content, match_parent, and 0dp (match constraint) as responsive alternatives to hard-coded dimensions.

GridLayout

Do not assume that switching a child to match_parent will make it expand in a GridLayout. Android’s GridLayout.LayoutParams documentation says that GridLayout does not distinguish MATCH_PARENT from WRAP_CONTENT for children; expansion is governed by its flexibility principle.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What about fill_parent?

fill_parent is the older name, now deprecated in favor of match_parent. Android’s ViewGroup.LayoutParams reference records MATCH_PARENT as introduced in API level 8 and marks FILL_PARENT deprecated starting at API level 8. Use match_parent in current examples; when reading older XML, treat fill_parent as the legacy equivalent.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.