Reputation: 226
I just need some hint on this. I have fragment A & Fragment B.
Fragment A --> Fragment B
At first launch, the layout is of Fragment A is fine (Picture 1: first screen initial /2. first screen when scrolled). But after going to Fragment B, & returning back to fragment A. The last item in recyclerview goes below screen by about 60 dp as shown in Picture 3. I added marginBottom (60dp) at NestedScrollView and could see the last item at returning back. But it gave margin at first launch of fragment.
I think there is problem of CoOrdinatorLayout and NestedScrollView but couldn't solve this problem.
Layout of Fragment A :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
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.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:orientation="vertical"
>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView_ProfilePicture"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/profile_picture"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
app:layout_collapseParallaxMultiplier="0.7"
/>
<Button
android:id="@+id/button_Login"
style="@style/Base.TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_weight="0.10"
android:background="@drawable/rectangular_button"
android:text="@string/form_btn_login"
android:textAllCaps="true"
android:textColor="@color/white"/>
<TextView
android:id="@+id/textView_Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/home_username_color"
android:textSize="26dp"
/>
<TextView
android:id="@+id/textView_NumberOfProduct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/home_product_no_color"
android:textSize="24dp"
/>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarHome"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageViewDrawerMenu"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_menu"
android:padding="8dp"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewHome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<com.github.clans.fab.FloatingActionButton
android:id="@+id/fab_Scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/ic_plus"
fab:fab_colorNormal="@color/app_primary"
fab:fab_colorPressed="@color/app_primary_dark"
fab:fab_colorRipple="@color/app_primary_dark"/>
</FrameLayout>
Upvotes: 1
Views: 1244
Reputation: 354
Add on class file
mRecyclerview.setNestedScrollingEnabled(true);
Upvotes: -2