android - Bottom Sheet Fragment with margins and collapsed height - android

My class extends from BottomSheetDialogFragment and is working fine by now. But I dont get it how to set the collapsed height (setPeekHeight on BottomSheet Behavior).
Another thing I want to know is: How to set the margin left and right only when the BottomSheet is collapsed? Like this screenshots below.
collapsed:
expanded:

Related

Fixed footer in Bottomsheet Compose

I'm trying to add a fixed button at the bottom of compose bottomsheet. The button should be visible at all times in collapsed state and should stay static at the bottom as the user slides up through the sheet.
Sample behavior: https://medium.com/#KaneCheshire/sticky-ui-in-android-bottom-sheet-3d65ea1d20dc
I have tried using a subcompose layout and placed the button by subtracting button height from visible sheet height like so;
constraints.maxHeight - sheetState.offset.value - ctaPlaceable.height
but with this I cant achieve the desired transition when the sheet is sliding down from collapsed to dismissed as the button remain fixed at their position. I want the buttons to slide down when the sheet is being dismissed and remain fixed in their position when the sheet is sliding up.
Can anyone help?

Android Standard Bottom Sheet with animated toolbar when sheet expanded

I have a fragment, within that fragment I want to display a standard bottom sheet. When the sheet is expanded Id like to display a toolbar at the top of the sheet, with close/collapse button, something like presented on https://material.io/components/sheets-bottom#behavior under Behaviour -> Visibility -> FullScreen
To my surprise Im struggling to achieve similar effect - tried applying different scroll flags (app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed") however Im getting opposite results - toolbar is visible when sheet is half extended and disappars when I scroll the sheet to the top.

MotionLayout collapses RecyclerView header but does not expand

I have created a sample project that can reproduce this issue.
Expected Result
When I scroll the bottom RecyclerView upwards, the top RecyclerView collapses
When I scroll the bottom RecyclerView downwards, the top RecyclerView expands
Observed Result
When I scroll the bottom RecyclerView downwards, the top RecyclerView does not expands
Additional information
Try to hold your swipe when the top RecyclerView collapses at the half, and then swipe down. You can see half of the top items being cut.
This only happens for the collapsing View being/includes a RecyclerView.
GIF
(Ignore the changing color - it is just a result of compressing GIF)
Question
Did I do anything wrong or it is a MotionLayout bug?
I came up with an alternative solution.
For easier communication, I will use rvTop for the top RecyclerView and rvBottom for the bottom RecyclerView.
Instead of "shrinking" rvTop, the idea is to "hide" it instead.
So instead of let rvBottom constraint to the bottom of rvTop, we need to introduce a new invisible line in between them, and use MotionLayout to animate this invisible line upwards, while keeping the alpha change of rvTop.
In order to do this, we have to make rvBottom opaque, otherwise it will overlap with the fading rvTop.
I have updated the code in the sample project to demonstrate the changes.
And the effect is:
EDIT:
Another alternative is to remove rvTop's constraint to top of parent after the transition.
Yes, this will make it simply scroll with the rvBottom; but we can add a little bit of translationY to make it "scroll slower than rvBottom".
This can handle the case where you cannot make rvBottom opaque, for example the page itself uses a gradient background.
The effect looks like this:

How to implement Bottom Sheet, where components above depends of the size and motion this Bottom Sheet?

I need to implement this UI.
This is layout with a closed Bottom Sheet.
This is layout with an open Bottom Sheet.
I implemented Bottom Sheet as in the design, but my problem is that the Bottom Sheet climbs over the Recycler View. I want to implement this like in design - when I open the Bottom Sheet, my Recycler View will decreased dynamically in size. Please tell me how to set this behavior for Bottom Sheet. How can I get distance between Toolbar and top part of Bottom Sheet and how I can reduce Recycler View size with animation when Bottom Sheet was opened?

How to collapse existing content when a bottomsheet is expanded?

I have a layout that contains a CoordinatorLayout with a ScrollView and a BottomSheet. When I set the state of the BottomSheet to expanded the BottomSheet overlaps the content of the ScrollView. I would like the height of the ScrollView to be reduced by the height of the BottomSheet. How can I achieve this?
I am going to move to using a BottomSheetDialog for now.
Thank you!
I attempted to make a solution that adjusted the layout when the bottome sheet was expanded, but ended up settling on using a BottomSheetDialog:
https://developer.android.com/reference/android/support/design/widget/BottomSheetDialog.html

Categories

Resources