2016-04-07 40 views
0

我剛剛將Android支持庫的新更新安裝到了版本23.2.1.0,並且當我運行該項目時,我遇到了一個前所未有的問題。我正在使用卡片視圖,這些視圖顯示在碎片內充氣的recyclerview容器內部。這些cardview在列表項目之間有很大的差距。所有recyclerviews似乎都有同樣的問題。回收站視圖之間的巨大差距

爲recyclerview容器中的代碼如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/rv" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:scrollbars="vertical" /> 
    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/progressBar" 
     android:layout_centerInParent="true" 
     android:layout_marginTop="20dp" 
     android:background="@drawable/ProgressBarStyle" 
     android:visibility="invisible" /> 
</RelativeLayout> 

列表項的代碼如下:更新之前

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="0dp"> 
    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:cardPreventCornerOverlap="false" 
     app:cardUseCompatPadding="false" 
     android:id="@+id/cv"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="16dp"> 
      <refractored.controls.CircleImageView 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:id="@+id/person_photo" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="16dp" 
       android:src="@drawable/profile2" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/person_name" 
       android:layout_toRightOf="@+id/person_photo" 
       android:layout_marginTop="10dp" 
       android:textStyle="bold" 
       android:layout_alignParentTop="false" 
       android:textSize="20sp" /> 
     </RelativeLayout> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 

一切都很好。我不知道爲什麼更新搞砸了一切。這就是列表項目現在的樣子。您將不得不上下滾動查看其他項目。

enter image description here

+0

檢查http://stackoverflow.com/questions/35728179/recyclerview-items-with-big-empty-space-after-23-2-0 –

回答

3

嘗試在你的listItem XML設置根LinearLayout的高度wrap_content

+0

哦是的。這解決了它。多謝,夥計!在以前的版本中,主包裝的完整高度未顯示,只有內部內容顯示在回收列表視圖中。 –

+0

Omg,這救了我。非常感謝。但是,解釋是什麼? – Recomer

+0

結帳http://stackoverflow.com/a/35728185/4321808解釋 –