MARSH
MARSH

Reputation: 281

Unable to set bottom margin in given layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:orientation="vertical"
    android:weightSum="2">

    <ScrollView
        android:id="@+id/gview1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.15"
        android:orientation="vertical"

        >

        <com.prolificinteractive.materialcalendarview.MaterialCalendarView
            android:id="@+id/calendarView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:mcv_arrowColor="@color/colorPrimary"
            app:mcv_selectionColor="@color/colorPrimary" />

    </ScrollView>

    <LinearLayout
        android:id="@+id/gview2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:id="@+id/headertext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/calendarView"
            android:background="#1d925c"
            android:gravity="center"
            android:padding="10dp"
            android:textColor="#ffffff" />

        <RelativeLayout
            android:id="@+id/rl_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/headertext"
            android:layout_margin="10dp"
            android:background="@drawable/shadow"
            android:orientation="vertical">

            <fragment
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/caneclIcon" />

        </RelativeLayout>
    </LinearLayout>


</LinearLayout>

This is my xml i have set google map fragment in bottom layout when i set margin as 10 then top ,left and right i am able to set but from bottom its not setting can any one please suggest me what i am doing wrong why i am not able to set bottom margin in given xml.

Upvotes: 0

Views: 58

Answers (1)

dev
dev

Reputation: 260

Your weightSum is 2, so layout_weight of both child layouts in parent layout should match weightSum.

 <LinearLayout
    android:id="@+id/gview2"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".85"
    android:orientation="vertical">

change like this, here layout_weight is .85, Scrollview layout_weight is 1.15, which makes weightSum 2. and your marginBottom will reflect

Upvotes: 1

Related Questions