2016-09-16 41 views
1

我面临这个奇怪的问题,其中我的Recycleview是高度的wrap_content,但它占用了屏幕的全部高度,而我的内容仅占用了一半的屏幕空间。 我读到这是一个bug,它在23.2.1中修复。我使用: -Recycleview wrap_content问题

compile 'com.android.support:appcompat-v7:24.1.1' 
compile 'com.android.support:recyclerview-v7:24.1.1' 

在XML另外,我还没有添加任何具体的: -

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

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_marginBottom="@dimen/margin_10" 
    android:layout_marginLeft="@dimen/margin_20" 
    android:layout_marginRight="@dimen/margin_20" 
    android:layout_marginTop="@dimen/margin_10" 
    android:layout_weight="1"> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipe" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycleview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#FF0000" /> 
    </android.support.v4.widget.SwipeRefreshLayout> 

    <include layout="@layout/layout_circular_progress_bar" /> 
</FrameLayout> 

正如你可以从图片看我的内容只有一半,圆形的白色部分和下面的红色部分是额外的。如何删除这个? enter image description here

回答

0

我最近面临同样的问题,这是一个错误; 我用简单的黑客解决了它: 将任何线性布局或任何视图放置在recyclerview下面并将其设置为隐形,这将有助于回收商适应包装高度测量。

第二种解决方案是制作自定义的线性布局,并在recyclerview.setlayoutmanager中使用它

+0

第一点工作。设置重量为1的线性布局 –