我正在尝试实现类似于 Field Trip 应用程序的功能,如下图所示:
下面是我的 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/