NestedScrollView cuts / overlaps the bottom of nested fragments

I have a problem with NestedScrollView because it shortens the bottom of the view.

I have a FragmentA with a schema:

 <RelativeLayout> <android.support.design.widget.CoordinatorLayout> <android.support.design.widget.AppBarLayout> <android.support.design.widget.CollapsingToolbarLayout> <ImageView/> <android.support.v7.widget.Toolbar/> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView> <LinearLayout> <FrameLayout> <!-- fragment added dynamically--> </FrameLayout> <FrameLayout> <!-- fragment added dynamically--> </FrameLayout> <FrameLayout> <!-- fragment added dynamically--> </FrameLayout> </LinearLayout> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.FloatingActionButton/> </android.support.design.widget.CoordinatorLayout> 

I add dynamic fragments to each FrameLayout .

I made SS what it looks like when I launch the application for the first time: Screen for the first time I put a pad in each layout to see what happens. green CoordinatorLayout , red NestedScrollView , orange LinearLayout inside NestedScrollView .

Now I am replacing FragmentA with FragmentB and returning to FragmentA again, and I have something like this: wrong sorting

Does anyone know what I'm doing wrong?

This is my layout for FragmentA :

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorP" android:padding="5dp" android:layout_above="@+id/przyciski"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="160dp" 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" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginBottom="25dp" app:expandedTitleMarginEnd="0dp" app:expandedTitleMarginStart="48dp" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <ImageView android:id="@+id/header" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" app:layout_collapseMode="parallax" android:contentDescription="descp" /> <android.support.v7.widget.Toolbar android:id="@+id/anim_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> <android.support.v4.widget.NestedScrollView android:id="@+id/scrollableview" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorRedCalendar" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:padding="5dp"> <LinearLayout android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorAccent" android:orientation="vertical" android:padding="5dp"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/frameForInfo" android:minHeight="100dp" android:focusableInTouchMode="true"> </FrameLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/frameForCalendar" android:minHeight="100dp" android:focusableInTouchMode="true"> </FrameLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/frameForGraph" android:minHeight="100dp" android:focusableInTouchMode="true"> </FrameLayout> </LinearLayout> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/fab_margin" android:clickable="true" app:layout_anchor="@+id/appbar" app:layout_anchorGravity="bottom|right|end" app:backgroundTint="@color/colorAccent" android:id="@+id/floatingButtonLog" /> </android.support.design.widget.CoordinatorLayout> </RelativeLayout> 

EDIT: I am compiling with:

 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:support-v4:23.2.1' compile 'com.android.support:design:23.2.1' compile 'com.jjoe64:graphview:4.2.1' } 

I add Fragments to FrameLayout with:

 infoFragment = new InfoFragment(); infoFragment.setLogs(mapLogIn, mapLogOut, monthToDispaly, yearToDispaly); infoFragment.setPracownik(mPracownik); if (getChildFragmentManager().findFragmentByTag("INFO") == null) { getChildFragmentManager() .beginTransaction() .add(R.id.frameForInfo, infoFragment, "INFO") .commit(); }else { getChildFragmentManager() .beginTransaction() .replace(R.id.frameForInfo, infoFragment, "INFO") .commit(); } 

How do I replace FragmentA with FragmentB :

 ((AppCompatActivity)getActivity()).getSupportFragmentManager() .beginTransaction() .replace(R.id.frameForFragment, edit) .addToBackStack(null) .commit(); 

And how do I get back from FragmentB to FragmentA :

 getFragmentManager().beginTransaction().remove(AddingPerson.this).commit(); if (getFragmentManager().getBackStackEntryCount()>0){ getFragmentManager().popBackStack(); } 

It looks like the NestedScrollView has been cut at the bottom because (if you are looking at ss) there is no fill frame at the bottom.

I notice that when I return to FragmentA (it displays if it is not displayed correctly), and I replace the fragments inside the NestedScrollView at the bottom of the NestedScrollView .

Here is a YT video.

UPDATE

I found a temporary answer here . I added:

 android:layout_gravity="fill_vertical" android:layout_marginBottom="?attr/actionBarSize" 

But it is written that this error is fixed in version 22.2.1, but it seems that this is not so. Does anyone know something about this?

+5
source share
3 answers

Try using:

 android:layout_marginBottom="?attr/actionBarSize" 

in your NestedScrollView

+1
source

try adding this to your nestedscrollview

 android:fillViewport="true" 
0
source

The accepted answer adds margin when the screen is rotated or when a soft keyboard is displayed. I fixed the addition of OnGlobalLayoutListener () to the main view and the call to the requestLayout () function for such a view from inside the listener.

0
source

Source: https://habr.com/ru/post/1259727/


All Articles