卡片视图未出现,滚动视图也无法正常工作

Card View is not appear and also scrollview is not working

<RelativeLayout>
    <android.support.v7.widget.CardView>
    .
    .//this card view is showing
    .
    </android.support.v7.widget.CardView>

     <ScrollView>

          <RelativeLayout>


                 <android.support.v7.widget.CardView>
                  .
                  .//this card view is not showing
                  .
                  </android.support.v7.widget.CardView>

                  <android.support.v7.widget.RecyclerView>

                  //data is previewing but not scrolling

                  </android.support.v7.widget.RecyclerView>

         </RelativeLayout>


    </ScrollView>



</RelativeLayout>

但是如果我将第二个 cardview 放在 scrollview 之外而不是显示。我不明白是什么问题。如果有人可以提供帮助,非常感谢。

我试过的解决方法:-

使用 nestedscrollview 而不是滚动视图。

如果问题格式或风格不符合 Stack Overflow 指南,请告诉我,以便将来我会以更好的方式提问。而不是对它投反对票。

编辑:

完成XML文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">


<android.support.v7.widget.CardView
    android:id="@+id/goal_status_card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
            android:id="@+id/goal_name"
            android:textAlignment="center"
            android:text="Blood Pressure"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_marginTop="@dimen/activity_horizontal_margin"
            android:weightSum="3"
            android:orientation="horizontal"
            android:id="@+id/goal_brief"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <customView.timeline_segement
                android:layout_weight="1"
                android:layout_width="100dp"
                android:layout_height="wrap_content">

            </customView.timeline_segement>

            <customView.timeline_segement
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

            </customView.timeline_segement>

            <customView.timeline_segement
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

            </customView.timeline_segement>

        </LinearLayout>

    </LinearLayout>


</android.support.v7.widget.CardView>


<ScrollView
    android:fillViewport="true"
    android:layout_below="@+id/goal_status_card"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <android.support.v7.widget.CardView
            android:layout_margin="@dimen/activity_horizontal_margin"
            android:id="@+id/goal_card_team"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:text="Your Care Team"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

                <LinearLayout
                    android:weightSum="3"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_weight="1.5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ImageView
                            android:id="@+id/doctor_photo"
                            android:layout_width="wrap_content"
                            android:layout_height="60dp" />

                        <TextView
                            android:textAlignment="center"
                            android:id="@+id/doctor_name"
                            android:text="Dr Ankur"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent" />

                    </LinearLayout>


                    <ImageView
                        android:src="@drawable/applozic_ic_action_add"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_weight="1.6"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ImageView
                            android:id="@+id/care_manager_photo"
                            android:layout_width="wrap_content"
                            android:layout_height="60dp" />

                        <TextView
                            android:textAlignment="center"
                            android:id="@+id/care_manager_name"
                            android:text="Cm Ankit"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent" />

                    </LinearLayout>



                </LinearLayout>


            </LinearLayout>


        </android.support.v7.widget.CardView>

        <android.support.v7.widget.RecyclerView
            android:layout_below="@+id/goal_card_team"
            android:id="@+id/action_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </android.support.v7.widget.RecyclerView>

    </RelativeLayout>


</ScrollView>

谁能帮我解决这个问题??

回答自己的问题,如果以后有人遇到同样的问题,这里是正确答案:-

https://github.com/amardeshbd/android-recycler-view-wrap-content

使用LinearLayout 代替Relative 布局并将Recyclerview 包装到relativelayout。