0

I have a Scrollviewas my parent container which contains a map, and then some information below the map. It currently looks like the image below.

I'm trying to make it so that the map takes up half of the screen using layout_weight but I've had no luck. Can anyone tell me what I'm doing wrong?

enter image description here

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_weight="1">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <fragment
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            tools:context="com.thevisitapp.visitapp.PlacesActivity"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:id="@+id/map" />
    </LinearLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/summaryLabel"
                android:paddingLeft="16dp"
                android:background="@color/gray"
                android:text="summary"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/summary"
                android:layout_below="@+id/summaryLabel"
                android:paddingLeft="16dp"
                android:paddingTop="16dp"
                tools:text="actual summary"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/contactsLabel"
                android:background="@color/gray"
                android:layout_below="@+id/summary"
                android:paddingTop="5dp"
                android:paddingLeft="16dp"
                android:text="contact"/>
    </RelativeLayout>
</LinearLayout>

Rafa
  • 3,219
  • 4
  • 38
  • 70

1 Answers1

0

Try this

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">


        <fragment
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            tools:context="com.thevisitapp.visitapp.PlacesActivity"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:id="@+id/map" />


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:orientation="vertical">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/summaryLabel"
            android:paddingLeft="16dp"
            android:background="@color/gray"
            android:text="summary"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/summary"
            android:layout_below="@+id/summaryLabel"
            android:paddingLeft="16dp"
            android:paddingTop="16dp"
            tools:text="actual summary"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/contactsLabel"
            android:background="@color/gray"
            android:layout_below="@+id/summary"
            android:paddingTop="5dp"
            android:paddingLeft="16dp"
            android:text="contact"/>
    </RelativeLayout>
    </LinearLayout>
</ScrollView>
Mohammad Tauqir
  • 1,817
  • 1
  • 18
  • 53
  • I get the same result. It's all squished towards the top like in my previous example – Rafa Sep 20 '15 at 16:57
  • In your `PlacesActivity` have you handled anything for map ? – Mohammad Tauqir Sep 20 '15 at 16:59
  • Yes I have. It worked fine when i didn't have a scrollview, everything was nicely spaced, but I know I'm going to run out of room with all the things I'm planning on sticking in, so I switched over to the scrollview and that happened – Rafa Sep 21 '15 at 00:31