This is a common issue becoming less apparent when testing on Lollipop or later.
When using standard layouts (such as
FrameLayout, RelativeLayout etc.) the default behavior is that child views get drawn in order they are added or inflated.
The fix would look similar to this:
<FrameLayout>
<!-- Content will be drawn first - below the toolbar. -->
<FrameLayout android:id="@+id/main_content" />
<!-- Toolbar will be drawn next - above the content. -->
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" />
</FrameLayout>
However since Lollipop the
android:elevation attribute can override this behavior. Since elevation defines precise position along the Z axis views with higher elevation values will be drawn above those with lower elevation values.