Android 填充高度为“wrap_content”的视图

Android 填充高度为“wrap_content”的视图,android,xml,Android,Xml,所以我使用了一个回收视图,还有一些卡片。我想在点击时在卡片上获得一个覆盖图,它应该覆盖所有内容,但不改变视图的大小。无法对卡的大小进行硬编码,因为内容具有不同的尺寸 <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <!--contents and stuff--> <View andr

所以我使用了一个
回收视图
,还有一些卡片。我想在点击时在卡片上获得一个覆盖图,它应该覆盖所有内容,但不改变视图的大小。无法对卡的大小进行硬编码,因为内容具有不同的尺寸

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <!--contents and stuff-->

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000" />

</RelativeLayout>

上面的例子正是我想要实现的,但是这显然不起作用,因为
视图和
相对视图的高度是相互关联的

我如何使
视图
覆盖
RelativeLayout
中的所有内容

编辑
澄清:我遇到的问题与点击、覆盖或诸如此类的事情无关。我对只涉及评论中建议的
框架布局
相对性yout

积分有疑问

基本上,我所要做的就是将
RelativeLayout
(如我的问题所示)封装在
FrameLayout
中,并将
视图从
RelativeLayout
移动到
FrameLayout

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!--contents and stuff-->

    </RelativeLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000" />

</FrameLayout>

在评论中建议使用
框架布局时,可获得积分

基本上,我所要做的就是将
RelativeLayout
(如我的问题所示)封装在
FrameLayout
中,并将
视图从
RelativeLayout
移动到
FrameLayout

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!--contents and stuff-->

    </RelativeLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000" />

</FrameLayout>


您在单击卡片时是否切换视图的可见性?您是否尝试使用框架布局而不是相对布局???@Agileinja还不太清楚,我甚至无法让视图正确覆盖卡片,因为我不知道如何告诉它填充视图。@thunder413我没有,没有。这会有什么不同(没有框架布局方面的经验)?您发布的XML代码是否描述了一张卡片?或者它描述了包含RecyclerView的代码?当你点击一张卡片时,你是否切换视图的可见性?你是否尝试使用框架布局而不是相对布局???@AgileNinja还不太清楚,我甚至无法让视图正确覆盖卡片,因为我不知道如何告诉它填充视图。@thunder413我还没有,不。这会有什么不同(没有框架布局方面的经验)?您发布的XML代码描述的是一张卡片吗?还是它描述了包含RecyclerView的代码?