I am using a fragment to show the comments and rating, I want to put a effect like when we pull the fragment up or down it get closed or disappear with animation, like the layout of facebook comment.
This is my layout, It contains a Recyclerview.
I want that when I pull this layout up or down, it closes like this as facebook comment layout does.
Can you please suggest me a way as how can I achieve this functionality.
One simple trick, that might work depending on your usecase, is to implement it using BottomSheetBehaviour
.
Advantages:
public void onSlide(@NonNull View bottomSheet, float slideOffset)
You would structure you xml something like this snippet:
<android.support.design.widget.CoordinatorLayout >
<android.support.design.widget.AppBarLayout >
<android.support.design.widget.CollapsingToolbarLayout >
<android.support.v7.widget.Toolbar />
</android.support.design.widget.CollapsingToolbarLayout >
</android.support.design.widget.AppBarLayout >
<include layout="@layout/content_layout" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
app:behavior_hideable="false"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<include layout="@layout/bottom_sheet_content_view" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
Some help to get started:
https://medium.com/@nullthemall/new-bottomsheet-caab21aff19b
https://code.tutsplus.com/articles/how-to-use-bottom-sheets-with-the-design-support-library--cms-26031
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