2015-07-21 99 views
0

我想做一个CollapsingToolbarLayout。我已经成功实施了。我在CollapsingToolbarLayout中有一个视差图像。在CollapsingToolbarLayout之外,我有一个带3张卡片的NestedScrollView。当我滚动卡片时,CollapsingToolbarLayout会折叠显示工具栏,卡片会移动到操作栏下方的顶部。但是他们并没有在动作栏之外滚动。其结果是,我无法查看第三张牌的内容。滚动不响应NestedScrollView在android

我错过了什么吗?这里是我的代码

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

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

    <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:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/artist_image_profile_page" 
      android:layout_width="match_parent" 
      android:layout_height="300dp" 
      android:src="@mipmap/ic_default_artist" 
      app:layout_collapseMode="parallax" 
      app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" 
      android:clickable="true" 
      android:transitionName="selectedArtistImage" 
      android:scaleType="centerCrop" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_scrollFlags="scroll|enterAlways"/> 

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

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

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/scroll_card_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

     <android.support.v7.widget.CardView 
      android:id="@+id/card_video" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      app:cardBackgroundColor="@color/background_light_color"> 

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

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/video" 
        android:textSize="18sp" 
        android:textColor="@color/primary_text_dark_color" 
        android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="300dp" 
        android:layout_marginTop="10dp" 
        android:background="@color/background_dark_color"></RelativeLayout> 
      </LinearLayout> 

     </android.support.v7.widget.CardView> 

     <android.support.v7.widget.CardView 
      android:id="@+id/card_releases" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_margin="5dp" 
      app:cardBackgroundColor="@color/background_light_color"> 

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

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/releases" 
        android:textSize="18sp" 
        android:textColor="@color/primary_text_dark_color" 
        android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 


      </LinearLayout> 

     </android.support.v7.widget.CardView> 

     <android.support.v7.widget.CardView 
      android:id="@+id/card_biography" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_margin="5dp" 
      app:cardBackgroundColor="@color/background_light_color"> 

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

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/biography" 
        android:textSize="18sp" 
        android:textColor="@color/primary_text_dark_color" 
        android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

       <TextView 
        android:id="@+id/artist_biography" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="16sp" 
        android:text="@string/test" 
        android:layout_marginTop="5dp" 
        android:textColor="@color/secondary_text_color"/> 

      </LinearLayout> 

     </android.support.v7.widget.CardView> 

    </LinearLayout> 

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

## Heading ##</android.support.design.widget.CoordinatorLayout> 
+0

通知使用的库的版本... – HBB20

回答

0

的问题是你有指定layout_height最后两个cardview(机器人:layout_height = “100dp”)。将它替换为“wrap_content”,它应该可以顺利运行。