-1

Ich versuche, etwas ähnliches zu Field Trip App wie dieses Bild zu erreichen:RecyclerView am unteren Rand der Karte Android

enter image description here

Unten ist mein Fragment Layout xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <com.google.android.gms.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/map_recyclerView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:reverseLayout="true" 
     android:divider="@null" 
     android:layout_gravity="center_horizontal|bottom"/> 
</FrameLayout> 

Aber bin RecyclerView kann nicht angezeigt werden, stattdessen belegt Map die volle Höhe.

Antwort

2

versuchen, diese Anwendung LinearLayout und gibt android:layout_weight="1" zu Ihrem <com.google.android.gms.maps.MapView und gibt android:layout_weight="1" zu Ihrem <android.support.v7.widget.RecyclerView wie unten Layout

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

    <com.google.android.gms.maps.MapView 
    android:id="@+id/mapView" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"/> 

    <android.support.v7.widget.RecyclerView 
    android:id="@+id/map_recyclerView" 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:layout_weight = "1" 
    android:orientation="horizontal" 
    app:reverseLayout="true" 
    android:divider="@null" 
    android:layout_gravity="center_horizontal|bottom"/ 
    /> 
</LinearLayout> 
2

Nehmen Sie LinearLayout innerhalb FrameLayout und verwenden Sie GewichtSumme;

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/main_rel" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:weightSum="2.0" > 

<com.google.android.gms.maps.MapView 
    android:id="@+id/mapView" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"/> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/map_recyclerView" 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal" 
    app:reverseLayout="true" 
    android:divider="@null" 
    android:layout_gravity="center_horizontal|bottom"/> 

</LinearLayout> 
2

Verwenden LinearLayout mit Prozentgewichten (60% für maps und 40% für RecyclerView)

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

    <com.google.android.gms.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.60"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/map_recyclerView" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:layout_weight = "0.40" 
     android:orientation="horizontal" 
     app:reverseLayout="true" 
     android:divider="@null" 
     android:layout_gravity="center_horizontal|bottom"/> 
</LinearLayout> 
0
<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 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:orientation="vertical"> 

     <com.google.android.gms.maps.MapView 
      android:id="@+id/mapView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/map_recyclerView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_marginBottom="5dp" 
      android:layout_gravity="center_horizontal|bottom" 
      android:orientation="horizontal" 
      app:reverseLayout="true" /> 


    </RelativeLayout> 
0

Das Problem ist mit FrameLayout verwendet. Ändern Sie einfach FrameLayout in LinearLayout, wird gut sein. So sollte es es sein:

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

    <com.google.android.gms.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/map_recyclerView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:reverseLayout="true" 
     android:divider="@null" 
     android:layout_gravity="center_horizontal|bottom"/> 
</LinearLayout> 
0

Nehmen lineares Layout mit vertikaler Ausrichtung innerhalb der mainLayout

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/mainLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:id="@+id/linearLayout" 
     android:weightSum="2"> 

     <com.google.android.gms.maps.MapView 
      android:id="@+id/mapView" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/map_recyclerView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|bottom" 
      android:divider="@null" 
      android:orientation="horizontal" 
      app:reverseLayout="true" /> 
    </LinearLayout> 
</FrameLayout> 

Ich hoffe, der Code wird Ihnen helfen

Verwandte Themen