我正在尝试在一个Fragment中使用两个RecyclerView。其中一个是水平对齐的RecyclerView,另一个是垂直对齐的RecyclerView。但只有水平对齐的RecyclerView可见。(如果我在布局文件中更改RecyclerViews的顺序,则可以看到垂直对齐的RecyclerView,因此我相信RecyclerViews没有问题。)
根据其他类似问题的答案,我已经在两个RecyclerView中都添加了"layout_weight=1"。但第二个RecyclerView仍然不显示。
这是我的布局文件:
根据其他类似问题的答案,我已经在两个RecyclerView中都添加了"layout_weight=1"。但第二个RecyclerView仍然不显示。
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/CategoryPageRecyclerView"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:scrollbars="none" />
<android.support.v7.widget.RecyclerView
android:id="@+id/ItemsRecyclerView"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
我觉得SwipeRefreshLayout可能会有问题。你有什么想法可以修复它吗?
android:layout_height="100dp"
),将第二个设置为match_parent
。 - Markaos