viewpager2 interaction with SwipeRefreshLayout - android

I have viewpager2 with 4 fragments. 3 of them have SwipeRefreshLayout to refresh async task data in particular fragments.
When using SwipeRefreshLayout and viewpager2 the gestures are somehow conflicting. ie. swype down to refresh makes screen so sensitive, that a little move to left or right also makes page screen change and refresh icon is freezing or the processis unfinished.
my goal is to make gestures independent, so for example when i start to swype down SwipeRefreshLayout, then vp2 is disabled so it it is not interfere with SRL.
This was not happening when using standard viewpager with SwipeRefreshLayout, gestures were not conflicting, but I need to use "setUserInputEnabled" in VP2. any idea how to mitigate this behaviour and should i mitigate it at SwipeRefreshLayout level or within viepager2 code?

It looks problem is resolved when I added to my scrollview:
android:nestedScrollingEnabled="true"
Final code of the fragment layout then looks like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/some_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/activity_background"
tools:context="some_fragment_name">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:nestedScrollingEnabled="true" <<<<------ HERE the change
android:id="#+id/some_id">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/sensors_relative_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="some_package_name">
<TextView
android:id="#+id/some_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#android:color/white"
android:gravity="center"
android:textColor="#android:color/black"
android:textStyle="bold"
android:layout_marginTop="5sp"
android:layout_marginLeft="5sp"
android:layout_marginRight="5sp"
android:textSize="20sp" />
...

EDIT: Update as 1.1.0 has been released on July 22, 2020
The problem was due to a bug in SwipeRefreshLayout, which has been resolved by Version 1.1.0. To use it, just upgrade to that version by adding the following line in the dependencies of your Gradle file:
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
See issueTracker for the bug history: [ViewPager2] SwipeRefreshLayout should not ignore requestDisallowInterceptTouchEvent. Note that there's also a workaround described there (extending SwipeRefreshLayout and overriding "requestDisallowInterceptTouchEvent").

If you have RecyclerView in SwipeRefreshLayout you need to wrap RecyclerView in FrameLayout aur any other layout and set nestedScrollingEnabled="true" on Layout not set on RecyclerView.
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/swipeRefreshLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/media_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

Related

RecyclerView not working inside a ScrollView properly

My app and the RecyclerView was working fine until I add the second RecyclerView on to the fragment. Since I added the second fragment, I added a ScrollView to the fragment. Then I faced some issue with the scrolling within the recyclerview, it didn't scroll smoothly. After going through a lot of articles online including StackOverflow, I changed the ScrollView with androidx.core.widget.NestedScrollView. This fixed the issue with scrolling but some major issue occured. The loading of items in the RecyclerView took more time, when I hit the searchbutton, that's there on the menu bar at the top, it took long time to expand the search field and some times app show 'not responding' message. Some articles say add .setNestedScrollingEnabled=false and I added it like the following in onCreateView() of the fragment. But I am still facing the issue.
I am using kotlin
binding.rv_home_items.isNestedScrollingEnabled=false
binding.rv_home_categories.isNestedScrollingEnabled=false
Following is the xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorOffWhite"
android:orientation="vertical"
tools:context=".ui.fragments.HomeFragment">
<FrameLayout
android:id="#+id/framelayout_category"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_home_categories"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:paddingBottom="15dp" />
<ImageButton
android:id="#+id/ibutton_show_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="5dp"
android:background="#drawable/ic_show_category" />
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/framelayout_category">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.denzcoskun.imageslider.ImageSlider
android:id="#+id/image_slider"
android:layout_width="match_parent"
android:layout_height="200dp"
android:visibility="gone"
app:iss_auto_cycle="true"
app:iss_corner_radius="5"
app:iss_delay="0"
app:iss_error_image="#color/colorDarkGrey"
app:iss_period="2500"
app:iss_placeholder="#color/colorDarkGrey"
app:iss_selected_dot="#drawable/default_selected_dot"
app:iss_unselected_dot="#drawable/default_unselected_dot"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_home_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/image_slider"
android:layout_marginBottom="50dp" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
I am completely stuck on my project, any help with this is highly appreciated
Edit:
When I launch the app, in a few seconds it's shows a message that the app is not responding.
If you have more than one RecyclerView and even all of them have same scroll direction, seems ConcatAdapter can be preferred solution.
ConcatAdapter enables sequentially combine multiple adapters to a single RecyclerView.

RecyclerView inside Scroll View in the fragment is not working? [duplicate]

For my app I am using a RecyclerView inside a ScrollView where the RecyclerView has a height based on its content using this library. Scrolling is working but it's not working smoothly when I scroll over the RecyclerView. When I scroll over the ScrollView itself it is scrolling smoothly.
The code I am using to define the RecyclerView:
LinearLayoutManager friendsLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext(), android.support.v7.widget.LinearLayoutManager.VERTICAL, false);
mFriendsListView.setLayoutManager(friendsLayoutManager);
mFriendsListView.addItemDecoration(new DividerItemDecoration(getActivity().getApplicationContext(), null));
The RecyclerView in the ScrollView:
<android.support.v7.widget.RecyclerView
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="#+id/friendsList"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Try doing:
RecyclerView v = (RecyclerView) findViewById(...);
v.setNestedScrollingEnabled(false);
As an alternative, you can modify your layout using the support design library. I guess your current layout is something like:
<ScrollView >
<LinearLayout >
<View > <!-- upper content -->
<RecyclerView > <!-- with custom layoutmanager -->
</LinearLayout >
</ScrollView >
You can modify that to:
<CoordinatorLayout >
<AppBarLayout >
<CollapsingToolbarLayout >
<!-- with your content, and layout_scrollFlags="scroll" -->
</CollapsingToolbarLayout >
</AppBarLayout >
<RecyclerView > <!-- with standard layoutManager -->
</CoordinatorLayout >
However this is a longer road to take, and if you are OK with the custom linear layout manager, then just disable nested scrolling on the recycler view.
Edit (4/3/2016)
The v 23.2 release of the support libraries now includes a factory “wrap content” feature in all default LayoutManagers. I didn’t test it, but you should probably prefer it to that library you were using.
<ScrollView >
<LinearLayout >
<View > <!-- upper content -->
<RecyclerView > <!-- with wrap_content -->
</LinearLayout >
</ScrollView >
I only needed to use this:
mMyRecyclerView.setNestedScrollingEnabled(false);
in my onCreateView() method.
Thanks a lot!
You can use this way either :
Add this line to your recyclerView xml file :
android:nestedScrollingEnabled="false"
Or in java code :
RecyclerView.setNestedScrollingEnabled(false);
Hope this helped .
You can try with both the ways with XML and programmatically. But the issue you may face is (below API 21) by doing it with XML will not work . So it's better to set it programmatically in your Activity / Fragment.
XML code:
<android.support.v7.widget.RecyclerView
android:id="#+id/recycleView"
android:layout_width="match_parent"
android:visibility="gone"
android:nestedScrollingEnabled="false"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayoutBottomText" />
Programmatically:
recycleView = (RecyclerView) findViewById(R.id.recycleView);
recycleView.setNestedScrollingEnabled(false);
Using Nested Scroll View instead of Scroll View solved my problem
<LinearLayout> <!--Main Layout -->
<android.support.v4.widget.NestedScrollView>
<LinearLayout > <!--Nested Scoll View enclosing Layout -->`
<View > <!-- upper content -->
<RecyclerView >
</LinearLayout >
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
I had similar issues (I tried to create a nested RecyclerViews something like Google PlayStore design). The best way to deal with this is by subclassing the child RecyclerViews and overriding the 'onInterceptTouchEvent' and 'onTouchEvent' methods. This way you get complete control of how those events behave and eventually scrolling.
Replacing ScrollView with NestedScrollView resulted into smooth scrolling to the bottom.
Summary of all answers (Advantages & Disadvantages)
For single recyclerview
you can use it inside Coordinator layout.
Advantage - it will not load entire recyclerview items. So smooth loading.
Disadvantage - you can't load two recyclerview inside Coordinator layout - it produce scrolling problems
reference - https://stackoverflow.com/a/33143512/3879847
For multiple recylerview with minimum rows
you can load inside NestedScrollView
Advantage - it will scroll smoothly
Disadvantage - It load all rows of recyclerview so your activity open with delay
reference - https://stackoverflow.com/a/33143512/3879847
For multiple recylerview with large rows(more than 100)
You must go with recyclerview.
Advantage - Scroll smoothly, load smoothly
Disadvantage - You need to write more code and logic
Load each recylerview inside main recyclerview with help of multi-viewholders
ex:
MainRecyclerview
-ChildRecyclerview1 (ViewHolder1)
-ChildRecyclerview2 (ViewHolder2)
-ChildRecyclerview3 (ViewHolder3)
-Any other layout (ViewHolder4)
Reference for multi-viewHolder - https://stackoverflow.com/a/26245463/3879847
Kotlin
Set isNestedScrollingEnabled to false for every RecyclerView that is under the scrolling view
val recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
recyclerView.isNestedScrollingEnabled = false
Using XML Layout
<android.support.v7.widget.RecyclerView
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="#+id/friendsList"
android:layout_width="match_parent"
android:nestedScrollingEnabled="false"
android:layout_height="wrap_content" />
Every answer is same here. and i already used what everyone is suggested. Then i found that NestedScrollView is faster then ScrollView so
use
<androidx.core.widget.NestedScrollView
Instead of
<ScrollView
And use this as usual
recycleView.setNestedScrollingEnabled(false);
If you are using VideoView or heavy weight widgets in your childviews keep your RecyclerView with height wrap_content
inside a NestedScrollView with height match_parent
Then scrolling will work smooth as perfectly as you want it.
FYI,
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:nestedScrollingEnabled="false"
android:layout_height="wrap_content"
android:clipToPadding="false" />
</android.support.v4.widget.NestedScrollView>
Thanks Micro this was from your hint!
karthik
you can use ScrollView as a parent and NestedScrollView as a child.
like this:-
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/CL1">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/eventRV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/CL1" />
</androidx.core.widget.NestedScrollView>
XML code:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false" />
</android.support.v4.widget.NestedScrollView>
in java code :
recycleView = (RecyclerView) findViewById(R.id.recycleView);
recycleView.setNestedScrollingEnabled(false);
Or you can just set android:focusableInTouchMode="true" in your recycler view
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintlayout_main"
android:layout_width="match_parent"
android:layout_height="#dimen/layout_width_height_fortyfive"
android:layout_marginLeft="#dimen/padding_margin_sixteen"
android:layout_marginRight="#dimen/padding_margin_sixteen"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<TextView
android:id="#+id/textview_settings"
style="#style/textviewHeaderMain"
android:gravity="start"
android:text="#string/app_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintlayout_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/padding_margin_zero"
android:layout_marginTop="#dimen/padding_margin_zero"
android:layout_marginEnd="#dimen/padding_margin_zero"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/constraintlayout_main">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>
This code is working for in ConstraintLayout android
Simple Add this line into your JAVA class
list.setNestedScrollingEnabled(false);
I myself had this issue, there is a recycler view within a scrollview and the scroll doesn't seem to be smooth. The cause for my issue was having the scrollview on top of the recycler view which was not needed for my requirement. So after I removed the scrollview and added the android:scrollbars="vertical" for recycler view, the scrolling was smooth.
After 3 days of research, I solved smooth scroll issue in my project.
The problem is <layer-list> drawable set in the background of item_user.xml file so it takes GPU time for rendering that's why scrolling not smooth. So please dont use complex <layer-list> drawable in the background of adapter item.
My problem is solved by above solution, below option is not useful for me
setNestedScrollingEnabled
setHasFixedSize
setItemViewCacheSize

How to make an Android view containing an embedded RecyclerView to scroll as a single piece?

I have this piece of layout or Android which is problematic:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="#+id/influencerMainPhotoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
<android.support.v7.widget.RecyclerView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/photos_list"
android:name="com.company.android.InfluencerFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:context="com.company.android.InfluencerFragment"
tools:listitem="#layout/fragment_photo"/>
</LinearLayout>
The problem is that the embedded RecyclerView is doing nested scrolling (ie. it scrolls within itself) - I don't want this.
I'd like to the entire screen to scroll as a single piece.
I tried to set "view.setNestedScrollingEnabled(false);" (on the LinearLayout view) but it says it works only for API 21 and above. My project is set to min API 15.
What can I do to make the entire screen scroll as a single piece?
You can replace View with ViewCompat(v4 compat lib):
https://developer.android.com/reference/android/support/v4/view/ViewCompat.html
where you have the setNestedScrollingEnabled(boolean); method.

Android UI Resizing because of keyboard?

I'm developing a chat application. Recently I changed the Chat, Activity (no lag) to Fragment (so many lag when resizing) because I wanted to build a flexible UI but now there is my problem : When the keyboard show up or disappear the UI resizing is very laggy.
I tried to changed adjustpan and other inside the manifest -> not working
When I remove the recyclerview from de chat -> it works, no lag when the keyboard show up.
So I guess the problem is here (I'm not sure),
I noticed this error RecyclerView: No adapter attached; skipping layout
I tried to fix it with other post on stackoverflow but no success. The error also appears when I scroll the recyclerview or when the keyboard appears.
When I have lot of messages inside my adapter it's very laggy when the view is resizing.
About the architecture
The MainActivity have one container.
the container can contain fragments : FamilyFragment, SettingFragment, RootChatFragment
RootChatFragment -> building flexible UI (Contact Fragment and ChatFragment) or just Contact Fragment if it's mobile view
Can someone help me ? (sorry for my bad english)
Here a screenshot when I close the keyboard.
UPDATED, FIXED
Using android:layout_weight="value" was the problem but I don't know why.
Old one
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:fillViewport="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.myapp.fragments.SpaceContact"
android:id="#+id/contact_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<fragment android:name="com.myapp.fragments.SpaceChat"
android:id="#+id/chat_fragment"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
</RelativeLayout>
New one without lag
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:fillViewport="true">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.myapp.fragments.SpaceContact"
android:id="#+id/contact_fragment"
android:layout_width="350dp"
android:layout_height="match_parent" />
<fragment android:name="com.myapp.fragments.SpaceChat"
android:id="#+id/chat_fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/contact_fragment"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
</RelativeLayout>

RecyclerView containing CardView's won't scroll (not in focus?) unless after clicked once

My RecyclerView contains a list of CardView
xml for MainActivity:
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.RecyclerView
android:id="#+id/view_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
<FloatingActionButton/>
</android.support.design.widget.CoordinatorLayout>
I use an adapter for the RecyclerView above to contain the Cards.
xml used to inflate ViewHolder inside the adapter:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/relativeLayout"
android:paddingTop="2dp"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.CardView
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="#android:color/holo_red_light"
card_view:cardPreventCornerOverlap="true"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="3dp"
card_view:contentPadding="7dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:id="#+id/relat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="false"
android:padding="10dp">
<TextView/>
//...
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
To make the Cards clickable, I tried all solutions in these - two popular posts , but I always have this weird bug:
The list of Cards won't scroll when I start the app for the first time, unless I click on the RecyclerView once. It's as if the RecyclerView is not in focus initially.
Also, if I get rid of all click listeners or similar ways to make the CardView's clickable, and only keep the focusable code in xml:
android:focusable="true"
android:focusableInTouchMode="false"
, then it does scroll right away, but as soon as I add any click (listener) mechanism, or even include "android:clickable="true"" for the ViewHolder, that bug re-emerges.
Please advise. Thank you
You should never nest a RecyclerView inside a ScrollView. Just remove the NestedScrollView and the RecyclerView should take care of its scrolling behavoiur.
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar/>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/view_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.design.widget.CoordinatorLayout>
Turns out the scrolling issue is not related to the RecyclerView. It was due to an open source widget I used which anchored to the RV and somehow interfered with the focusing/scrolling/touch interception. Finally got rid of this bug after days of looking elsewhere..
thank you all the same

Categories

Resources