Recyclerview Cannot Be Scrolled

Can't scroll RecyclerView

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!

Can't scroll RecyclerView

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!

Unable to scroll RecyclerView

I sloved it.
this is Cover RecyclerView

    <!--menu-->
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
tools:openDrawer="end"
android:layout_height="match_parent"
android:id="@+id/drawer_layout">

So I replace it To :

<!--menu-->
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
tools:openDrawer="end"
android:layout_height="match_parent"
android:id="@+id/drawer_layout">

<!-- RecyclerView-->

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_marginTop="250dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>

RecyclerView doesn't scroll

Put the content of your layout within DrawerLayout

<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/headernav"
android:orientation="vertical">

<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Date"
android:textColor="@color/white"
android:textSize="18sp" />

<TextView
android:id="@+id/recentLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Recent Logins"
android:textColor="@android:color/background_light"
android:textSize="24sp" />
</LinearLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</LinearLayout>

</ FrameLayout>

<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="start"
android:background="@color/white"
app:headerLayout="@layout/admin_nav_header"
app:itemIconTint="@color/black"
app:itemTextColor="@color/colorAccent"
app:menu="@menu/admin_menu">

</android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

Android RecyclerView in ConstraintLayout doesn't scroll

For a RecyclerView to scroll, one of two things must be true:

  • The RecyclerView has a smaller height than all of its items
  • The RecyclerView is inside a scrolling parent

ConstraintLayout is not a scrolling parent, so we have to make sure that the RecyclerView is "too small", which will cause it to let the user scroll its children.

The easiest way is to just give the RecyclerView a defined height, with something like this:

android:layout_height="200dp"

Of course, this only works if you know ahead of time exactly how big you want your RecyclerView to be, and this is not usually the case.

A better solution is to use constraints to define the height of your RecyclerView. The first step is to give it a height of 0dp, which can be thought of as "match constraints". In other words, you're telling the system to make the RecyclerView as tall as it needs to be in order to satisfy its top and bottom constrains.

Next, you must define top and bottom constraints. The simplest would be to constrain the RecyclerView's top to the parent's top and its bottom to the parent's bottom. That might look like this:

android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"

Or, you could position the RecyclerView relative to some other views. That might look like this:

android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/viewAboveMe"
app:layout_constraintBottom_toTopOf="@+id/viewBelowMe"

As long as you combine a height of 0dp with both top and bottom constraints (and as long as your RecyclerView is actually smaller than its contents), this will allow your RecyclerView to scroll as desired.

Original

Your RecyclerView is using wrap_content for its height. If you want it to scroll, you must provide a fixed height, or, inside a ConstraintLayout, use 0dp for its height and give it an app:layout_constraintBottom_xxx attribute.

RecycleView not scrolling

If you put NestedScrollview, remove it.

And add this in your addressesRv recyclerview

android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"

Nested RecyclerView not scrolling

Editted

you have to disable parent recyclerView touch event while scrolling child
Recyclerview

latestBidsInCenter.setOnTouchListener(new View.OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == child.getId()) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) {
bidCenter.requestDisallowInterceptTouchEvent(false);
} else {
bidCenter.requestDisallowInterceptTouchEvent(true);
}
}

return super.onTouchEvent(event);
}
});


Related Topics



Leave a reply



Submit