android: how do I add padding to a LinearLayout inside a FrameLayout

android, android-framelayout, android-layout

Solution

you have

android:marginLeft="20dp"
android:marginRight="20dp"

instead change it to:

android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"

If it still doesnot work, put this layout inside another layout and set the margins to the other layout.

Problem

I have a FrameLayout with many children. One of the children is a LinearLayout. I want the width of the LinearLayout to `match_parent` but about 90% so; which means I want to add some sort of `paddingLeft/Right` or `margingLeft/Right`. But when I add the padding or margin, it is not applied in the Graphical Layout. How do I do this correctly? ``` <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/blue" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:background="@color/red" android:marginLeft="20dp" android:marginRight="20dp" android:orientation="vertical" > .... ```

Original source