2017-02-25 64 views
0

我在滾動視圖中使用了兩個recyclerview。下面是我的XML代碼:滾動視圖中的多個Recyclerview問題添加不必要的空間

<?xml version="1.0" encoding="utf-8"?> 
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:focusableInTouchMode="true"> 


     <FrameLayout 
      android:id="@+id/movieTitleView" 
      android:layout_width="match_parent" 
      android:layout_height="120dp" 
      android:background="#40C4FF"> 

      <TextView 
       android:id="@+id/movie_title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="20dp" 
       android:layout_marginLeft="40dp" 
       android:layout_marginTop="40dp" 
       android:textColor="#FFFFFF" 
       android:textSize="20sp" /> 

     </FrameLayout> 

     <RelativeLayout 
      android:id="@+id/movieSynopsisView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/movieTitleView"> 

      <ImageView 
       android:id="@+id/movieImg" 
       android:layout_width="140dp" 
       android:layout_height="100dp" 
       android:layout_marginLeft="3dp" 
       android:layout_marginTop="6dp" 
       android:src="@drawable/sample" /> 

      <TextView 
       android:id="@+id/tvReleaseDate" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="6dp" 
       android:layout_toRightOf="@+id/movieImg" 
       android:text="releasedate" 
       android:textSize="14sp" /> 

      <TextView 
       android:id="@+id/vote" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/tvReleaseDate" 
       android:layout_marginTop="4dp" 
       android:layout_toRightOf="@+id/movieImg" 
       android:text="voteavera" 
       android:textSize="14sp" /> 

      <Button 
       android:id="@+id/btnFavourite" 
       android:layout_width="100dp" 
       android:layout_height="53dp" 
       android:layout_below="@+id/vote" 
       android:layout_toRightOf="@+id/movieImg" 
       android:text="@string/btn_favourite" /> 


      <TextView 
       android:id="@+id/tvSynopsis" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/movieImg" 
       android:layout_marginLeft="10dp" 
       android:layout_marginTop="10dp" 
       android:text="synopsis" 
       android:textSize="13sp" /> 

      <View 
       android:id="@+id/movieDivider" 
       android:layout_width="350dp" 
       android:layout_height="1dp" 
       android:layout_below="@+id/tvSynopsis" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="2dp" 
       android:background="#000000" /> 


      <android.support.v7.widget.RecyclerView 
       android:id="@+id/rvTrailer" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/movieDivider" /> 


      <android.support.v7.widget.RecyclerView 
       android:id="@+id/rvReview" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_below="@id/rvTrailer" 
       /> 
     </RelativeLayout> 

    </RelativeLayout> 
</ScrollView> 

`

首先recyclerview創建,我可以能夠滾動。但第二個回收視圖 還有一個額外的空間。我不添加任何填充。第二個recycleview在屏幕下方創建,即在頁面加載時創建。第一個回收視圖佔用全屏。

我錯過了什麼嗎?

任何人都可以幫助我嗎?

回答

0

更換第二RecyclerView的android:layout_height = 「match_parent」 屬性到Android:layout_height = 「WRAP_CONTENT」 如下:

<android.support.v7.widget.RecyclerView 
    android:id="@+id/rvReview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/rvTrailer" /> 
+0

我改變了高度WRAP_CONTENT。仍然問題沒有解決。 Iam使用recycler視圖編譯'com.android.support:recyclerview-v7:25.1.1' –