androidandroid-layoutandroid-recyclerview

Can't scroll RecyclerView


I can't scroll my RecyclerView to the end. It cut off my last element and I completly don't know why. I have another RecyclerView in my project, which also seems to be broken. Broken RecyclerView

Here is my layout code:

<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:id="@+id/container"
    android:padding="10dp">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cv"
        app:cardCornerRadius="2dp"
        app:cardUseCompatPadding="true">

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="220dp"
            android:orientation="horizontal">

(...)

        </RelativeLayout>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/textView17"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="HISTORIA"
        android:id="@+id/textView17"
        android:layout_below="@+id/cv"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

Another broken RecyclerView:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.praca_inz.Fragments.PetrolFragment">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:scaleType="center"
        android:src="@drawable/ic_editor_mode_edit"
        android:layout_marginBottom="70dp"
        android:layout_marginRight="15dp"
        android:layout_marginEnd="15dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>

Any ideas, because I don't have any.


Solution

  • There was a problem with ViewPager in MainActivity layout. The solution was to set a paddingTop parameter, to 105dp (to cover Toolbar and TabLayout) and delete app:layout_behavior="@string/appbar_scrolling_view_behavior" parameter.

    Before:

    <android.support.v4.view.ViewPager
       android:id="@+id/viewpager"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       app:layout_behavior="@string/appbar_scrolling_view_behavior"  /> 
    

    After:

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="105dp"/>
    

    Thank you @oguzhand, for directing me to solution!