2016-02-20 56 views
3

我有一個協調器佈局,它由appbarlayout和nestedscrollview組成。問題是,當我打開該活動時,nestedscrollview的某些部分默認隱藏在展開的操作欄後面(差異顯示在圖像中)。Appbarlayout與NestedScrollView重疊

This is what I getThis is what it should be

XML文件:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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


    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:contentScrim="@color/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/ivToolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:adjustViewBounds="true" 
      android:scaleType="fitXY" 
      android:alpha="0.6" 
      app:layout_collapseParallaxMultiplier="0.7" /> 

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

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

<android.support.v4.widget.NestedScrollView 
    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"> 
     ...... 
     ....... 

我無法弄清楚什麼是這裏的問題,並在網上的任何地方找不到。也許這是一個錯誤。請檢查。

+1

爲什麼在NestedScrollView中設置_app_behavior_overlapTop =「 - 100dp」_? – Rick

+0

啊!我其實只是想看看這會發生什麼。之前也沒有面對這個問題。現在刪除它。 – Yashasvi

+0

似乎無法用該佈局文件重現此操作。 –

回答

0

我遇到了同樣的問題,將NestedScrollView的佈局高度設置爲android:layout_height =「wrap_content」爲我解決了這個問題。

希望它可以幫助

+0

它不起作用 – OMArikan

0

我由具有的FrameLayout裏面的NestedScrollView像解決了這個問題,這

<FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <android.support.v4.widget.NestedScrollView 
     android:background="@color/main_color_white" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     ............... 
     ............. 
</android.support.v4.widget.NestedScrollView> 
    </FrameLayout> 

或者你可以嘗試添加填充到您的NestedScrollView這樣

<android.support.v4.widget.NestedScrollView 
     android:background="@color/main_color_white" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="?attr/actionBarSize"> 
     ................ 
     ................ 
</android.support.v4.widget.NestedScrollView> 
0

不知道爲什麼,但this answer處理我的問題。 順便說一句我只有當我更改nestedScrollView中的任何視圖的可見性時才面臨這個問題

相關問題