Try to Understand the behavior of BottomSheet in android support library 23.2.1
<p>I am trying to implement Bottom sheet in one of my activities and I am kind of confused by the way it is behaving!</p>

<p>So here is the problem, I have an activity in which I am trying to show Bottom sheet and I see that:</p>

<ol>
<li><p>if we dont set the <code>app:behavior_peekHeight</code> property then the Bottom sheet never works </p></li>
<li><p>If you set the PeekHeight to something less than 30dp (basically just to hide it from screen)</p></li>
<li>If you set <code>app:behavior_peekHeight</code> to more than 30dp in layout file and try to set the state of <code>bottomSheetBehavior</code> to <code>STATE_HIDDEN</code> in you onCreate method your app crashes with this error</li>
</ol>

<p>caused by: </p>

<pre><code>java.lang.NullPointerException: Attempt to invoke virtual method
'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference             at    android.support.design.widget.BottomSheetBehavior.setState(BottomSheetBehavior.jav    a:440)
at myapp.activity.SomeActivity.onCreate(SomeActivity.java:75)
</code></pre>

<p>I am really confused on why is it not allowing me to hide it in onCreate? or why cant we just set the peekHeight to 0 so that it is not visible on screen unless we call the <code>STATE_EXPANDED</code> or even not setting that property should default it to hide! or atleast I should be able to set it as hidden in my onCreate! </p>

<p>am I missing something? or is the behavior of the BottomSheet rigid?</p>

<p>my layout file for the BottomSheet is something like this:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="100dp"
android:orientation="vertical"
app:behavior_hideable="true"
app:behavior_peekHeight="40dp" &lt;!-- I cant set this less than 30dp just to hide--&gt;
app:layout_behavior="@string/bottom_sheet_behavior"
tools:context="someActivity"
android:id="@+id/addressbottomSheet"
tools:showIn="@layout/some_activity"&gt;
</code></pre>

<p>in my activity I am doing something like this:</p>

<pre><code>@InjectView(R.id.addressbottomSheet)
 View bottomSheetView;
@Override
protected void onCreate(Bundle savedInstanceState) {
....
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetView);

// only if I have set peek_height to more than 30dp
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); 
}
</code></pre>

<p>In my onclick I am doing this:</p>

<pre><code>@Override
public void onItemClick(View view, int position) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
</code></pre>