所以我正在使用RecyclerView
和一些卡片。我想在点击时在卡片上叠加一个叠加层,它应覆盖所有内容,但不会改变视图的大小。由于内容具有不同的尺寸,因此无法对卡的大小进行硬编码。
<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>
上面的例子几乎就是我想要实现的,但这显然不起作用,因为View
和RelativeLayout
的高度相互指向。
如何让View
覆盖RelativeLayout
内的所有内容?
编辑
澄清:我遇到的问题与点击,覆盖或类似的事情无关。我只是覆盖了RelativeLayout
。
答案 0 :(得分:0)
积分转到thunder413,以便在评论中建议FrameLayout
。
基本上,我所要做的只是将RelativeLayout
(如我的问题中所示)封装在FrameLayout
中,然后将View
移出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>