4

I have a coordinator layout, which consists of appbarlayout and nestedscrollview. The problem is that when I open the activity, some part of nestedscrollview is by default hidden behind the expanded action bar (difference shown in the images).

This is what I get This is what it should be

XML File :

<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">
        ...... 
        .......

I am not able to figure out what's the issue here, and couldn't find anywhere online. Maybe it's a bug. Please check.

Yash
  • 5,225
  • 4
  • 32
  • 65
  • 1
    Why have you set _app_behavior_overlapTop="-100dp"_ in NestedScrollView? – Rick Feb 20 '16 at 19:07
  • ah ! I was actually just trying to see what happens with this. Was facing the issue without it earlier also. Removed it now. – Yash Feb 20 '16 at 19:25
  • Can't seem to reproduce this with that layout file. – Andrew Seymour Feb 20 '16 at 19:46
  • @AndrewSeymour : I am getting this error. Maybe a device specific error? which device are you using? – Yash Feb 22 '16 at 05:31
  • I don't know what's happening. It looks like, if I add some extra height to the scroll view, it displays properly. Now, adding height here means I have tried with - adding one more random cardview OR increasing the height of any one cardview. Don't know what's the reason. – Yash Feb 24 '16 at 08:30
  • Does anyone find solution for this problem. I have same problem with almost same layout. And its just only appear on Galaxy S6 Edge +. – OMArikan Jul 04 '17 at 08:19

3 Answers3

0

I ran into the same problem, setting the layout height of the NestedScrollView to android:layout_height="wrap_content" fixed it for me.

Hope it helps

RWolfing
  • 1
  • 1
0

I solved this problem by having the NestedScrollView inside a FrameLayout like this

<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>

Or you can try adding a padding to your NestedScrollView like this

<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>
bmacharia
  • 1,026
  • 10
  • 12
0

Don't know why but this answer worked on my issue. Btw I faced with this problem only when I change visibility of any view inside nestedScrollView

OMArikan
  • 306
  • 1
  • 3
  • 9