android - Android Map底部的RecyclerView

标签 android google-maps android-layout android-recyclerview android-cardview

我正在尝试实现类似于 Field Trip 应用程序的功能,如下图所示:

enter image description here

下面是我的 fragment 布局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>

但是我看不到 RecyclerView,而是 Map 占据了整个高度。

最佳答案

使用具有百分比权重的 LinearLayout(maps 为 60%,RecyclerView 为 40%)

<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>

关于android - Android Map底部的RecyclerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45770804/

相关文章:

android - 安卓装机如何实现首页最佳显示?

android - 如何获取 Assets 中某个文件夹中的文件数量?

android - 如何在 Android 应用程序中查找 2 个地理点之间的距离(通过公路)?

Android:支持同一屏幕尺寸类型内的多种屏幕尺寸

java - 可以在不设置 Activity 的 ContentView 的情况下获取对 View 的引用

android - Dalvik格式失败,在ServerAssistant上出现错误1

javascript - 如何使用 javascript 将 LatlngBounds 对象传递给 nodejs 服务器

ios - 如何使用 Google Maps ios SDK 跟踪用户的位置并显示行进的路径

android - 如何添加 TextView 的日期选择器 onclick。表单中有多个日期字段

java - 虚拟键盘隐藏了屏幕的数据元素