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); } });