0

我只需要一些提示就可以了。我有片段A &片段BNestedscrollview中的Recyclerview隐藏了从片段回来的最后一个项目

片段A - >片段B

在首次启动时,布局片段A的是细(图1:第一屏幕滚动时初始/ 2个第一屏幕)。 。但是在进入片段B之后,&返回到片段A. recyclerview中的最后一项在屏幕上低于60dp,如图3所示。我在NestedScrollView中添加了marginBottom(60dp),并可以在返回时看到最后一个项目。但它在首次发布片段时提供了保证金。

我认为存在CoOrdinatorLayout和NestedScrollView的问题,但无法解决此问题。

布局片段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> 

First screen

Same first screen scrolled up, the last item is showing perfectly

After coming back from another fragment

+1

您应该包含您的布局图片和您的预期布局。 – UmarZaii

+0

我不认为你需要NestedScrollView,因为它只是包装Recyclerview。我想,即使是根FrameLayout也是不需要的。您可以在CoordinatorLayout本身中拥有FAB。你可以删除这些并检查? – Bob

回答

0

添加在类文件

mRecyclerview.setNestedScrollingEnabled(true); 
相关问题