2017-02-25 60 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' –