2017-04-25 62 views
1

在我的布局中,回收视图滚动,但图像是静态的,我想要的是当用户滚动图像也滚动回收视图请帮助我出来..! 我已经省略了id的空格 我试过滚动视图>相对布局/线性布局>(imageview +回收视图),但它使应用程序崩溃。Imageview和recycleview里面滚动视图与背景

<RelativeLayout 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:id="  " 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    tools:context="  " 

    > 


    <ru.egslava.blurredview.BlurredImageView 
     app:radius="0.8" 
     app:keepOriginal="true" 
     app:downSampling="2" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:id=" " 

     /> 

    <ImageView 
     android:layout_width="200dp" 
     android:layout_height="250dp" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="35dp" 
     android:id="  " 
     /> 

    <android.support.v7.widget.RecyclerView 
     android:id="  " 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:layout_below="  " 
     android:layout_marginTop="25dp" 
     android:scrollbars="vertical" 
     > 
    </android.support.v7.widget.RecyclerView> 


</RelativeLayout> 
+0

添加图像作为您RecyclerView的标题。 –

+0

http://stackoverflow.com/questions/29449329/recyclerview-with-scrolling-background检查了这一点。它类似于你的问题 –

回答

1
<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     > 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="your image"/> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="your image"/> 

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

    </LinearLayout> 

</android.support.v4.widget.NestedScrollView> 

,并在Java代码中做出mRecyclerView.setNestedScrollingEnabled(false); 滚动正确学分check this answer

0

按照本教程中,这就是你enter link description here

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/detail_backdrop_height" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleTextAppearance="@android:color/transparent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

       <ImageView 
        android:id="@+id/backdrop" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:fitsSystemWindows="true" 
        android:scaleType="centerCrop" 
        app:layout_collapseMode="parallax" /> 

       <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true" 
        android:gravity="center_horizontal" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/love_music" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/backdrop_title" 
         android:textColor="@android:color/white" 
         android:textSize="@dimen/backdrop_title" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/backdrop_subtitle" 
         android:textColor="@android:color/white" 
         android:textSize="@dimen/backdrop_subtitle" /> 

       </LinearLayout> 
      </RelativeLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

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

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

    <include layout="@layout/content_main" /> 

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