There is a layout and handler code.
BottomSheetBehavior does not work. We remove the map fragment, bottomSheetBehavior works.
How to use BottomSheetBehavior with a map?

 <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"> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" /> <Button android:id="@+id/btClick" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="clickme" /> <android.support.v4.widget.NestedScrollView android:id="@+id/vBottom" android:layout_width="match_parent" android:layout_height="200dp" android:background="#ccff0000" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </android.support.v4.widget.NestedScrollView> 

and code in onCreate

  findViewById(R.id.btClick).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View view = findViewById(R.id.vBottom); BottomSheetBehavior behavior = BottomSheetBehavior.from(view); behavior.setState(BottomSheetBehavior.STATE_EXPANDED); } }); 
  • Is it just a fragment with a map that works? - Android Android
  • @AndroidAndroid yes, quite. link to library added to build.gradle, api key specified in meta - Alexandr Motorin

1 answer 1

I solved the problem with a crutch:

 <CoordinatorLayout> <Fragment/><!--карта--> <CoordinatorLayout id1> <NestedScrollView id2 BottomSheetBehavior/> </CoordinatorLayout> </CoordinatorLayout> 

id1 is a container for View id2 with BottomSheetBehavior . id1 intercepts the touch, so you need to change its visibility when calling and hiding BottomSheetBehavior .

So you can call BottomSheetBehavior using, for example, a button. However, it is not possible to display it as a scroll from the bottom of the screen.