Android 当向布局中添加其他内容时,RecyclerView将消失

Android 当向布局中添加其他内容时,RecyclerView将消失,android,android-layout,android-recyclerview,Android,Android Layout,Android Recyclerview,我有一个选项卡式的viewpager,其中禁止滑动到下一页。原因是,在片段内部,我有一个水平的RecyclerView,它应该可以获得touch事件 片段XML: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" xmlns:android="http://schemas.a

我有一个选项卡式的viewpager,其中禁止滑动到下一页。原因是,在片段内部,我有一个水平的RecyclerView,它应该可以获得touch事件

片段XML:

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

        <TextView
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:text="Federal Representatives"
            android:fontFamily="sans-serif-medium"
            android:textSize="20sp"
            android:paddingTop="15dp"
            android:paddingLeft="15dp"
            android:textColor="#000000"
            xmlns:android="http://schemas.android.com/apk/res/android" />


    <android.support.v7.widget.RecyclerView
        android:id="@+id/federalPager"
        android:scrollbars="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

</LinearLayout>

但是如果我同时保留它们,则只会显示TextView,而不会显示RecyclerView


我缺少什么?

您的
TextView
具有以下属性:

android:layout_height="match_parent"

这告诉它和父母一样高。。。这样就把
RecyclerView
从底部推出。。。尝试将其改为
wrap\u content

aghhh,谢谢@Buddy。我已经看了半个小时了。