Java 我在一个片段中有两个RecyclerViews。但只显示了第一个
我试图在一个片段中包含两个RecyclerViews。其中一个是水平对齐的RecyclerView,另一个是垂直对齐的RecyclerView。但只有水平的RecyclerView可见。(如果我在布局文件中更改RecyclerViews的顺序,垂直的RecyclerViews是可见的,因此我很确定RecyclerViews没有问题。) 根据对类似问题的其他回答,我在两个RecyclerViews中都添加了Java 我在一个片段中有两个RecyclerViews。但只显示了第一个,java,android,android-fragments,android-recyclerview,swiperefreshlayout,Java,Android,Android Fragments,Android Recyclerview,Swiperefreshlayout,我试图在一个片段中包含两个RecyclerViews。其中一个是水平对齐的RecyclerView,另一个是垂直对齐的RecyclerView。但只有水平的RecyclerView可见。(如果我在布局文件中更改RecyclerViews的顺序,垂直的RecyclerViews是可见的,因此我很确定RecyclerViews没有问题。) 根据对类似问题的其他回答,我在两个RecyclerViews中都添加了layout\u weight=1。但是第二个回收视图仍然没有显示 这是我的布局文件: &l
layout\u weight=1
。但是第二个回收视图仍然没有显示
这是我的布局文件:
<?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>
我觉得布局有问题。关于如何解决此问题,您有什么想法吗?
SwipeRefreshView
只支持一个直接的子包装RecyclerView
s(位于LinearLayout
中),它会起作用
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
<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" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
希望这对您有所帮助,如果您有任何问题,请发表评论它确实有效!非常感谢:)顺便问一下,我如何才能避免将一半的窗口交给水平回收视图?编辑您的权重或完全删除它们,并将first的高度设置为dp中的某个值(
android:layout\u height=“100dp”
)其次,你可以接受答案,这样其他找到答案的人就会立即知道答案在你的案例中起了作用——答案在投票按钮下