How to properly scroll nested-scrollview? - android

How to properly scroll to a position in nestedscrollview which is inside a coordinate layout? When I use scrollTo(), it seems like the view inside AppBarLayout is loosing the ability to scroll down when I scroll to the end of NestedScrollView and coming back to top. What I need to know is how to programtically scroll to a position in nestedscrollview without causing problem with the normal behavior of collapsing layout.
Issue is similar to what is mentioned in this post:
The Coordinator layout doesn't Scroll up for a specific position
There is a Gif attached along with the above question:
https://i.stack.imgur.com/uSGfX.gif
I have tried the solution in above link, but it is not working.

Related

ViewPager within MotionLayout not scrolling correctly

I have a MotionLayout which basically contains an image and a ViewPager. The ViewPager renders a fragment with a RecyclerView in it.
At first the image has normal size, when i drag up, the image reduces its size and the ViewPager (with the RecyclerView within it) expands.
The problem is that the MotionLayout keeps intercepting the scroll action, so if the RecyclerView is expanded, and the user scrolls down, the MotionLayout will expand the image, rather than letting the RecyclerView scroll.
What i would expect is that the MotionLayout will expand the top image only if the RecyclerView has reached the first element, in that case since the RecyclerView cannot scroll anymore, the scroll action would be managed by the MotionLayout.
I am aware that within MotionLayout I can set the attribute moveWhenScrollAtTop="true" to get that behaviour, but that only works if there is just a RecyclerView, but not if the RecyclerView is within a ViewPager.
Has anyone faced this issue?
if your xml file contains nested scrollview just add android:nestedScrollingEnabled="false"

recyclerview inside scroll view affects scroll position

I have the following layout structure
--FrameLayout
--scrollview
--LinearLayout
--LinearLayout
--RecyclerView
--LinearLayout
When I arrive at the page, it seems to scroll to the recycler view.
I just want scroll position to be at the top when arriving at the page.
Seems odd, When i switch the order between the linearlayoout and recyclerview inside the scrollview, then the behaviour is correct - as in the scroll position is at the top
This worked for me:
mRecyclerView.setFocusable(false);
Although a lot of good answers here: How to scroll to top of long ScrollView layout?

Android Design Lib CollapsingToolbarLayout stops interact when horizontal RecyclerView is touched

I have an activity with CollapsingToolbarLayout for parallax effect(From Android Design Library) and FrameLayout where i set Fragment.
Fragments layout contains NestedScrollView.
Everything is working well except one moment. In NestedScrollView I have a horizontal RecyclerView with StaggerGridLayoutManager and when i scroll vertically from that recyclerview - parallax not starting. When i scroll from any other place of screen it works.
Seems it's problem with layout_behavior tag or loosing focus of NestedScrollView.
Does any one faced this problem ? Some ideas ?
Fuh! Got a solution! Disabling nested scroll on RecyclerView solved the problem.
recyclerView.setNestedScrollingEnabled(false);

Scroll a View before ListView like lollipop phone app

I have a layout with a linearLayout (top layout) and a listview under this.
What I want to do is like the phone app in Lollipop:
With the scrollbar I can scroll the contact list (top layout doesn't move)
When scroll the list with the finger, first the top layout is scrolling and once it is not visible anymore the listview scroll. When the top layout is visible the scrollbar doesn't move.
Someone has any idea how to do this trick?
What I'm thinking :
I can add the top layout to the header of listview, but the scrollbar take count of the header. And if I scroll with the scrollbar, the top layout will scroll
Trying to set a scrollListener to the listview, and translate the top view, but don't think it will be good and the scrollY is not available for listView
I think I can do something with a scrollView for the root layout, but I know it is not good to put a listview inside a scrollview.
I don't find any proper way to do this kind of feature...
EDIT: To be more clear, I want to translate the listview before I'm able to scroll the listview itself. Problem is when translate listview, the listview height will not expand.
I am also getting this problem in version 5.1 in lower version it's working fine.Try to use in 5.0 As it STABLE verson, also check another scrolling bug in 5.1 in this link here I could not comment so posting this as answer.

How to disable horizontal scrolling in android

I am using Horizontal scrolling in my application at some condition i don't want my horizontal scrolling to occur. so can any one help me how to disable the horizontal scrolling.
You should add another layout in your main view , and give requestFocus() to that view.
so your scroll view will get disable.
This solution work for me in my app.

Categories

Resources