2016-04-27 38 views
1

因此,我使用RecyclerView以及一些卡片。點擊時,我想在卡片上疊加一層覆蓋,該覆蓋應覆蓋所有內容,但不能更改視圖的大小。由於內容具有不同的尺寸,所以不可能對卡的尺寸進行硬編碼。填充包含`wrap_content`作爲高度的視圖

<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

你切換視圖的可見性時,你點了一張卡? – AgileNinja

+0

是否嘗試使用FrameLayout而不是相對? – thunder413

+0

@AgileNinja還不完全,我甚至無法看到正確覆蓋該卡,因爲我不知道如何告訴它來填充視圖。 – Timmiej93

回答

0

積分爲thunder413,建議在評論中提供FrameLayout

基本上,所有我需要做的就是封裝RelativeLayout(在我的問題所示)在FrameLayout,並移動ViewRelativeLayout進入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> 
相關問題