Skip to content Skip to sidebar Skip to footer

Does The Fill_parent Or Match_parent Attributes Work For A Relativelayout Object Really

Does the fill_parent or match_parent attributes work for a relativeLayout object really? Please see the following image:

Solution 1:

match_parent works on any view. As long as you don't have margins assigned to offset your view, it will expand to its parent size.

As for why you see it like this - do not rely too much on Android Studio designer. It is there to show a rough picture but is not a precise tool to rely on. Best case to see things are fine:

  • set a temporary different background color for your view (RelativeLayout in your case) and its parent layout
  • load the app and check if the parent color is shown around your relative layout

Post a Comment for "Does The Fill_parent Or Match_parent Attributes Work For A Relativelayout Object Really"