I am trying to implement a bottom sheet from the google design lib. Clicking on a button should open up bottom sheet which covers the whole activity window. Like when we open an email in Inbox by Gmail. But, it should open up from bottom and slide down to dismiss.
Button click should open up bottom sheet and on slide down or top left Close (X) button should close the sheet.
I have set up something like this:
<android.support.design.widget.CoordinatorLayout
.. >
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/bottom_sheet_behavior">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello Bottom Sheet !!" />
</android.support.v4.widget.NestedScrollView>
<include layout="@layout/content_my_activity" />
</android.support.design.widget.CoordinatorLayout>
And I am intializing it like this:
mBottomSheet = (NestedScrollView) findViewById(R.id.bottom_sheet);
mBottomSheetBehavior = BottomSheetBehavior.from(mBottomSheet);
mButton = (Button) findViewById(R.id.bottom_sheet_button);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
However, when I click on a button, the text just appears at the bottom. Overlapping the default existing content. And no black transparent tint behind the bottom sheet.
How can I make it full screen when clicking on button?
The reason I am not using a fragment here is, I have some(many) variables depending on the content of the bottom sheet. So, if I show a bottom sheet via fragment, I need to pass and receive all the data to and fro. To avoid this, I want it to be part of the activity.
Is there any way I can achieve this? Thanks for your help.