I am not really happy with this solution, but I have found it so far: try adding android:elevation="5dp" to your RelativeLayout , which is below the AppBarLayout :
<RelativeLayout android:layout_width="match_parent" android:layout_height="150dp" android:elevation="5dp" android:background="@android:color/holo_red_dark" />
This problem also arose for me, so I will try to investigate it a little more. (For me, the magic value of 5dp, don't ask why.)
Alternatively, you can place your views inside an AppBarLayout :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.nileshkashid.samplesearchbarapplication.Main2Activity"> <android.support.design.widget.AppBarLayout android:id="@+id/toolbar_view" android:layout_width="match_parent" android:layout_height="wrap_content"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@android:color/transparent" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="150dp" android:background="@android:color/holo_red_dark" /> </RelativeLayout> </android.support.design.widget.AppBarLayout> .... </RelativeLayout>
source share