So I am using the new support library behaviour for nested children scroll inside CoordinatorLayout and I have a view like this:
<com.....TodayBottomSheet
android:id="#+id/bottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/bottom_sheet_behavior"
app:behavior_hideable="false"/>
I have a requirement in my app, which isn't new and I need to temporarily disable scrolling of certain elements of a coordinator layout. For this bottomSheet, I need to disable the 'manual' scroll which will get triggered when touching and dragging the bottom of the screen. My requirement is to open/close the bottom sheet by pressing a button. I know how to do it programmatically, I just know how to disable the manual scroll.
And another problem which is related to this one, I need to temporarily disable recyclerView scroll listener when a certain action happens. I don't know how to do it since all the scrolling child of a coordinator layout are controlled by himself.
Check this solution.
Basically, onBottomSheetBehavior.STATE_DRAGGING set BottomSheetBehavior.STATE_EXPANDED.
Related
I have a BottomSheet with some non-clickable content. This BottomSheet is sliding over a RecyclerView.
Problem is when I tap on the BottomSheet, the RecyclerView item behind it fires (which of course shouldn't happen). The list also scrolls when scrolling on the BottomSheet.
I've tried to set android:clickable=false on the container of the BottomSheet with no effect.
Is there an obvious trick for preventing that?
You need to set android:clickable=true on the container of the BottomSheet instead of android:clickable=false.
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.
I have a vertically scrollable list using a RecyclerView. The layout I'm trying to implement is that when you scroll down far enough and reach a specific item, if you keep scrolling past this item it will stick to the bottom of the screen while the rest of the list continues to scroll behind it. Currently it's implemented by having a scroll listener on the RecyclerView and manually adjusting the position of the sticky view as required, but this is hacky and hard to build on.
Is there an easier way to have this kind of layout? I am currently investigating using a CoordinatorLayout but I'm not sure if it's the right tool for the job.
You can accomplish this using a CoordinatorLayout with a custom behaviour. The behaviour should be applied to the sticky view and make it appear/disappear as the RecyclerView scrolls. You have to override onStartNestedScroll in your behaviour to return true to receive calls for scroll changes.
The classic coordinator layout gives you the following [source]:
However, I don't want the top header views to scroll until they "become" a toolbar pinned at the top, with a shadow below. I want them all fixed (or pinned) but to show the shadow only the nested scroll view starts to scroll under the pinned ones. Something like the main app drawer on Marshmallow devices, where the "search bar" becomes pinned and the list of apps scroll under it.
Hope I made myself clear. Is there any easy way I could achieve that without listening for scroll events and handling this manually?
EDIT
Here is what I'm trying to achieve:
. Notice on the right image how there is now a shadow below the list of apps because the user scrolled the list.
Thank you!
This is exactly what you are looking for: HideOnScroll
Set actionBar elevation to 0 initially. Add a scroll listener to your scrolling element. When you detect it has scrolled (dy > 0) you set the actionBar elevation to 4dp(the default actionBar elevation) and back to 0dp at dy == 0.
In your scroll listener you can, at least for recyclerViews, use the canScrollVertically function to check if you're at the top or not.
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.