How to put Imageview Behind other layout

18,480

Solution 1

Put the image view above (on top - first child of the parent)
the layout in the xml file that way the image will be behind the layout

Solution 2

Use a FrameLayout. All items you put in there are stacked on top of each other.

Share:
18,480
Rahul Rawat
Author by

Rahul Rawat

Mobile Application Developer (Android, Blackberry, Windows Phone, IOS) . Reporting using Eclipse BI.

Updated on July 27, 2022

Comments

  • Rahul Rawat
    Rahul Rawat over 1 year

    I am using a imageview for animation so that it will look like movement left to right. but my image is displaying front of other views so that user is able to click on image. i am trying to display it behind the other view.

     <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout
        android:id="@+id/layout"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="@drawable/main_bg2"
        >
    
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content" >
    
         <Button
             android:id="@+id/languageChangePopup"
             style="?android:attr/buttonStyleSmall"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginBottom="10dp"
             android:layout_marginLeft="50dp"
             android:background="@drawable/startbtn" />
    
        <EditText
            android:id="@+id/showOutputEdit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="110dp"
            android:layout_marginTop="50dp"
            android:background="@drawable/display_textbx"
            android:cursorVisible="false"
            android:gravity="right|center"
            android:paddingLeft="70dp"
            android:paddingRight="70dp"
            android:textColor="#ffffff"
            android:textSize="45sp"
            android:textStyle="bold" />
    
        </LinearLayout>
    
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent" android:layout_weight="3.49">
    
            <TableLayout
                android:id="@+id/tableLayout1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="136dp"
                android:layout_marginTop="19dp" >
    
                <TableRow
                    android:id="@+id/tableRow5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                     >
    
                    <Button
                        android:id="@+id/clearBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/cbtn" />
    
                    <Button
                        android:id="@+id/sevenBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/sevenbtn" />
    
                    <Button
                        android:id="@+id/eightBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/eightbtn" />
    
                    <Button
                        android:id="@+id/nineBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/ninebtn" />
                </TableRow>
    
                <TableRow
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                     >
    
                    <Button
                        android:id="@+id/dotBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/dotbtn" />
    
                    <Button
                        android:id="@+id/fourBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/fourbtn" />
    
                    <Button
                        android:id="@+id/fiveBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/fivebtn" />
    
                    <Button
                        android:id="@+id/sixBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/sixbtn" />
                </TableRow>
    
                <TableRow
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                     >
    
                    <Button
                        android:id="@+id/zeroBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/zerobtn" />
    
                    <Button
                        android:id="@+id/oneBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/onebtn" />
    
                    <Button
                        android:id="@+id/twoBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/twobtn" />
    
                    <Button
                        android:id="@+id/threeBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@string/threebtn" />
                </TableRow>
    
                  </TableLayout>
    
    
    
            <LinearLayout
                android:id="@+id/layout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_marginTop="16dp"
                android:layout_toRightOf="@+id/tableLayout1"
                android:background="@drawable/operation_planet"
                android:orientation="vertical" >
    
                <Button
                    android:id="@+id/plusBtn"
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="20dp"
                    android:background="@drawable/addbtn" />
    
                <Button
                    android:id="@+id/minusBtn"
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:layout_marginRight="80dp"
                    android:layout_marginTop="30dp"
                    android:background="@drawable/minusbtn" />
    
                    <Button
                        android:id="@+id/multiplyBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="15dp"
                        android:layout_marginTop="20dp"
                        android:background="@drawable/multiplybtn" />
    
                    <Button
                        android:id="@+id/divideBtn"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginTop="30dp"
                        android:background="@drawable/dividebtn" />
    
            </LinearLayout>
    
                    <Button
                        android:id="@+id/equalToBtn"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:layout_marginBottom="21dp"
                        android:layout_toRightOf="@+id/tableLayout1"
                        android:background="@drawable/equaltobtn"
                        android:gravity="right" />
    
                    <ImageView
                        android:id="@+id/rocketImage"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignTop="@+id/layout"
                        android:background="@drawable/spaceship" />
    
        </RelativeLayout>
    
    </LinearLayout>