2015-07-21 97 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」,它應該可以順利運行。