The 29th Saltshaker The 29th Saltshaker - 1 month ago 8
Android Question

How do I display an ImageView underneath the middle of a LinearLayout?

So in my XML I have a LinearLayout

<LinearLayout ...>
...
</LinearLayout>


But I want to display an ImageView in the background of the LinearLayout, in the center, behind everything. How can I do this?

Answer

You can do something like

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/my_drawable"
    android:scaleType="fitCenter"
    />
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
</LinearLayout>

</FrameLayout>