Place a view over another view
<p>I have a custom toolbar in a separate file called <code>include_toolbar.xml</code>.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/include_toolbar"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /&gt;
</code></pre>

<p><a href="https://i.stack.imgur.com/nAYz4m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nAYz4m.png" alt="enter image description here"></a></p>

<p>In a layout for an activity, I want to display this toolbar at the top, a camera preview view and an image button on top of that.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;include layout="@layout/include_toolbar" /&gt;

    &lt;com.journeyapps.barcodescanner.CompoundBarcodeView
        app:zxing_result_view="@color/zxing_custom_result_view"
        android:id="@+id/activity_scan_barcodeView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"&gt;
    &lt;/com.journeyapps.barcodescanner.CompoundBarcodeView&gt;

    &lt;ImageButton
        android:id="@+id/activity_scan_flashlight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignLeft="@id/activity_scan_barcodeView"
        android:src="@drawable/btn_flashOn"/&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p><a href="https://i.stack.imgur.com/c5RcPm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c5RcPm.png" alt="enter image description here"></a></p>

<p>The <code>CompoundBarcodeView</code> is a component from <a href="https://github.com/journeyapps/zxing-android-embedded" rel="nofollow noreferrer">this</a> library.</p>

<p>The problem with the <code>LinearLayout</code> is that the image button is not displayed.</p>

<p>If I change it to <code>RelativeLayout</code>, the image button is displayed but now the toolbar is gone.</p>

<p><a href="https://i.stack.imgur.com/56c28m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/56c28m.png" alt="enter image description here"></a></p>

<p>How do I get both of them to display?</p>