Flipboard / bottomsheet

Android component which presents a dismissible view from the bottom of the screen
BSD 3-Clause "New" or "Revised" License
4.52k stars 596 forks source link

How to use using CoordinatorLayout? #145

Open hjJunior opened 8 years ago

hjJunior commented 8 years ago

I'm using

Where I put the bottomsheet ?

Polyterative commented 8 years ago

Same here

ZacSweers commented 8 years ago

Wherever you want? It doesn't take an opinion currently, so if there are cases that could be better documented please find out and share

hjJunior commented 8 years ago

Can You show me a example how to use when is using CoordinatorLayout + NestedScrollView ? Where I need to put bottomsheet?

ZacSweers commented 8 years ago

Not readily, no. I haven't tried and don't have any need to currently. I marked it as discussion hoping you guys would maybe try and report back with your findings. Sometimes you just have to dive in and get your hands dirty :)

hjJunior commented 8 years ago

Hey, I already had tried, But when I But before CoordinatorLayout, but I receive error that cannot be children, and when I use before CollapsingToolbarLayout, the bottomsheet stay under main content I also had tried before NestedScrollView, but in this case the bottomsheet is be over content, but... the header (AppBarLayout) stay over of bottomsheet.

ZacSweers commented 8 years ago

that was hard to read. Mind just making a sample project with examples of what you tried? Screen records would go a long way too

ypresto commented 7 years ago

This library shows the sheet outside of bottom edge of screen if BottomSheetLayout has app:layout_behavior="@string/appbar_scrolling_view_behavior". It maybe simply that this library does not support nested scrolling.

To work around, place BottomSheetLayout with match_parent in front of the content view. This perhaps means BottomSheetLayout can be simply view instead of wrapping layout.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        ...

    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <com.flipboard.bottomsheet.BottomSheetLayout
        android:id="@+id/bottom_sheet_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!-- NOTE: This empty view is required to make this works. See below code snippet. -->
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </com.flipboard.bottomsheet.BottomSheetLayout>

</android.support.design.widget.CoordinatorLayout>

Empty view is required because of below code. It assumes BottomSheetLayout has only and always one child view.

    public View getSheetView() {
        return getChildCount() > 2 ? getChildAt(2) : null;
    }

However sometimes get caught while scrolling. It might be caused by CoordinatorLayout which intercepts scroll events.

ypresto commented 7 years ago

Passing IntentIntentPickerSheetView to android.support.design.widget.BottomSheetDialog almost works well, but scrolling up always close bottom sheet because this library uses GridView which does not support nested scroll. To fix this RecyclerView or NestedScrollView should be used. #51

For BottomSheetLayout I have same opinion to below comment:

https://github.com/Flipboard/bottomsheet/issues/128#issuecomment-202590797

They have fixed most of the bugs so I'm not sure if anyone needs this library anymore.