CoordinatorLayout Custom Behavior with LinearLayout as child
<p>I want to implement a custom behavior on LinearLayout.
This is the structure of my xml:</p>

<pre><code>&lt;android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"&gt;
&lt;android.support.design.widget.AppBarLayout.../&gt;
&lt;android.support.v4.widget.DrawerLayout.../&gt;
 &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_behavior="com.xxx.BottomBarBehavior"
            android:layout_gravity="bottom|center_horizontal".../&gt;
&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p>The LinearLayout is inside CoordinatorLayout, below the DrawerLayout.
The LinearLayout is not moving up when the snackbar is shown. I just can't get my head around it. The layout is such that the DrawerLayout contains a ViewPager and this viewPager is populated by another xml by a fragment. And the snackbar is generated by an element in the recyclerView of this fragment.</p>

<p>This is how my BottomBarBehavior custom behavior class looks like:</p>

<pre><code>public class BottomBarBehavior extends CoordinatorLayout.Behavior&lt;LinearLayout&gt; {
public BottomBarBehavior(Context context, AttributeSet attrs) {}

@Override
public boolean layoutDependsOn(CoordinatorLayout parent, LinearLayout child, View dependency) {
    return ( dependency instanceof Snackbar.SnackbarLayout ) ||
            ( dependency instanceof DrawerLayout );
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, LinearLayout child, View dependency) {
    if( dependency instanceof Snackbar.SnackbarLayout ) {
        float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
        child.setTranslationY(translationY);
    }
    return true;
}
</code></pre>

<p>}</p>