2016-07-22 21 views
0

我已經使用RecyclerView來顯示一些使用Volley Library的JSON數據。我得到的是JSON數據,但最初在顯示數據時,格式正確。但是當我在recyclerview中滾動時,在行之間添加了巨大的空間。當在RecyclerView中滾動時會自動在行間添加空格

之前滾動 Before Scolling

enter image description here

滾動 這裏之後是row.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<TextView 
    android:id="@+id/tv_title" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/iv_image" 
    android:textSize="18sp" 
    /> 
</RelativeLayout> 

這裏的XML部件是XML

0添加recyclerview
<android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    /> 
</android.support.design.widget.CoordinatorLayout> 

在此先感謝。

回答

3

改變你的RelativeLayout的高度row.xml

android:layout_height="wrap_content " 
+0

謝謝,但它爲什麼最初顯示沒有任何空間? –

+0

我不知道,從邏輯上說,它不應該表現出這種方式。 – Drv

+0

我還有其他問題 –

0

爲wrap_content但爲什麼它最初顯示沒有任何空間?

ListView和RecycleView都有默認的視圖高度。 您使用match_parent,然後它將以默認高度進行,因爲在上面顯示的是空白區域。

如果你的TextView引力是垂直居中,那麼它將在頂部和底部都顯示空間。

相關問題