I've used a modified version of bottom-sheet library (here, based on this library, also wrote about it here), in order to have a nice transition between collapsed (AKA "peeked") state and expanded state.
The library had its issues, but in general, I've fixed them all.
Recently we've found that after going back from all ad-networks screens, back to one that has a bottom sheet, the bottom sheet gets into a weird state of being expanded.
I've decided that it's time to try the new bottom-sheet of the support library (shown here), but I've found that it has a lot of basic related issues:
And all this without even trying to handle what I wanted, which is the 3-phases I've done before.
At first, I thought I just don't use the library well, so I've tried 2 samples I've found:
I also tried some code I've found here on StackOverflow, but it seems all samples are about the same.
I've noticed they all have the same issues, so I've reported about them :
Now I try various ways to investigate and fix the issues, but I still fail to do so.
Is there any way to deal with those issues? What should be the correct code to use bottom sheets using the support library?
Bottom Sheet is a well-written material design component that performs enter/exit animations, respond to dragging/swiping gestures, etc. For using it in your project you should implement next dependencies into your app build.gradle file: implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
In android, there are two types of bottom sheets that use most of the time, Persistent Bottom Sheet and Modal Bottom Sheet. Persistent Bottom Sheet: It shows in-app content. It will display at the bottom of the mobile screen making some amount of the content visible.
UPDATE Link to the full answer in where you can find all the explanation about how to get full behaviors like Google Maps.
Helping you with what you want
what I wanted, which is the 3-phases I've done before
Using Support Library 23.x+ you can do it modifying default BottomSheetBehavior
adding one more stat with following steps:
CoordinatorLayout.Behavior<V>
BottomSheetBehavior
file to your new one.Modify the method clampViewPositionVertical
:
Add a new state
public static final int STATE_ANCHOR_POINT = X;
Modify the next methods: onLayoutChild
, onStopNestedScroll
, BottomSheetBehavior<V> from(V view)
and setState
(optional)
So now you have those states:
STATE_HIDDEN
STATE_COLLAPSED
STATE_DRAGGING
STATE_ANCHOR_POINT
STATE_EXPANDED.
You can use setBottomSheetCallback
like you do in original BottomSheetBehavior
The XML (without anything about parallax image like google maps) looks like:
<CoordinatorLayout>
<FrameLayout/>
<AppBarLayout>
<CollapsingToolbarLayout>
<Toolbar/>
</CollapsingToolbarLayout >
</AppBarLayout >
<NestedScrollView>
<LinearLayout/>
</NestedScrollView>
</CoordinatorLayout >
I'm going to add a link to the example project where you can find what you are looking for
And here is how its looks like:
[]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With