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" >
....
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With