2017-05-13 84 views
0

我有了膨脹的ViewHolder以下佈局的RecyclerView沒有顯示出與layout_height =「match_parent」孩子:API19與layout_height =「WRAP_CONTENT」一RelativeLayout的在RecyclerView

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    xmlns:app="http://schemas.android.com/apk/res-auto" 

    android:minWidth="25px" 

    android:minHeight="25px" 

    android:layout_width="match_parent" 

    android:layout_height="wrap_content"> 

    <android.support.percent.PercentRelativeLayout 

     android:id="@+id/imageRelative" 

     .... 

     .... 


    <LinearLayout 

     android:id="@+id/premiumBlockerView" 

     android:layout_height="match_parent" 

     android:layout_width="match_parent" 

     android:layout_alignParentRight="true" 

     android:layout_alignParentTop="true" 

     android:layout_alignParentLeft="true" 

     android:alpha="0.5" 

     android:background="@color/Black" 

     android:layout_alignBottom="@id/linearLayout1" /> 

</RelativeLayout> 

的RelativeLayout的內容變化(圖像,視頻,文本等),所以我無法知道高度(寬度是設備的寬度)。
我必須添加一個視圖(我的premiumBlockerView的LinearLayout),我將顯示爲半透明玻璃或不依賴於內容的類型。
的問題是,在premiumBlockerView高度= match_parent不起作用,這是百達爲零。因此,像其他人張貼的建議,我添加了layout_alignParent和alignBottom參數,這項工作角落找尋解決方案適用於API的超過20
更大的屬性格式現在,應用程序必須爲API 19工作,這項工作以防萬一不起作用。
你有什麼建議嗎?
謝謝!

回答

0

我面臨着同樣的問題太多。我很抱歉,我仍然無法找到的RelativeLayout一個完美的解決方案,但你可以通過使用ConstraintLayout或其他佈局而不是RelativeLayout的解決這個問題。

注: 如果設置父RelativeLayout的

機器人:layout_height = 「WRAP_CONTENT」>

和子視圖

機器人:layout_height = 「match_parent」

在RecylerView。

那麼子視圖將會得到

「WRAP_CONTENT」

,而不是match_parent,你可以通過閱讀RelativeLayout的onMeasure方法的源代碼中找到原因。

相關問題