Programmatically adding map fragment to container adds it to the bottom

120 Views Asked by At

I have a contact application. A contact can have multiple addresses. When viewing a contact, a loop iterates through the database data and adds the address(es) to a container, as shown in the image. However, I don't understand why the fragments are added all the way to the bottom of the container, and not right under the respective TextView for that specific loop iteration.

Why can I not place the fragment underneath the TextView and how can I do that?

This is how I create the map fragment and add it to the container:

FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    MapFragment mapFragment = MapFragment.newInstance();
    mapFragment.getMapAsync(onMapReadyCallback1());
    fragmentTransaction.add(R.id.dynamic_layout_holder, mapFragment);
    fragmentTransaction.commit();

And this is the xml container:

<LinearLayout
    android:id="@+id/dynamic_layout_holder"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
</LinearLayout>

0

There are 0 best solutions below