RecyclerView cutting off last item

前端 未结 7 890
孤街浪徒
孤街浪徒 2021-01-02 01:34

\"enter We can see here last item is partially visible. How can i fix this? layout.xml

相关标签:
7条回答
  • 2021-01-02 01:51

    I tried all the available option from most of possible site but I didn't get the solution. Then, I think can I use bottom padding? And Yes, It's work for me.

    I am sharing the code to you. Nothing more attribute required other than height, width & padding.

    android:paddingBottom="?attr/actionBarSize"

     <android.support.v7.widget.RecyclerView
        android:id="@+id/your id name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="?attr/actionBarSize"
        app:layout_constraintTop_toBottomOf="@+id/your field" />
    
    0 讨论(0)
  • 2021-01-02 01:51

    For others.Disabling nested scrolling in recyclerview also causes this problem in CoordinatorLayout with scrollable toolbar or tablayout. Because when you scroll recyclerview, toolbar or tablayout doesn't scroll.

    0 讨论(0)
  • 2021-01-02 01:59

    Easiest but not the best solution. Still works;

    Return +1 in the getItemCount() method of your RecyclerView.Adapter implementation and wrap your code in onBindViewHolder method override with a try-catch block.

    0 讨论(0)
  • 2021-01-02 02:05

    Use RelativeLayout instead of ConstraintLayout.It's working for me.

    0 讨论(0)
  • 2021-01-02 02:11

    I'm also having the same problem. In my opinion this happened because you set the AppBarLayout XML attribute android:fitsSystemWindows="true". To solve this i give the RecyclerView margin bottom equal to action bar size

     <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:id="@+id/recyclerView"
            android:layout_marginBottom="?attr/actionBarSize">
    
    0 讨论(0)
  • 2021-01-02 02:16

    @Lester was right problem was RecyclerView's wrap_content height. But changing match_parent was not working because. This layout was added to a fragment and that fragment was declared wrap_content. So I have changed fragment's height and recyclerview's height to match_parent and now problem solved.

    <fragment
            android:id="@+id/fragment"
            android:name="com.example.fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
    0 讨论(0)
提交回复
热议问题