nitz123
nitz123

Reputation: 27

How to bring view to the front in linearLayout

Is there a way to bring an imageView to the front of another imageView which is in a linearLayout? I try to place a little ball image in front of image and it does'nt work because the image is in a linearLayout :( Is there any way to make it possible?

 <LinearLayout
    android:id="@+id/HolesPlayer1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/tvGoolot13"
    android:layout_centerHorizontal="true" >

    <ImageButton
        android:id="@+id/imgBtn0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:background="@android:color/transparent"
        android:src="@drawable/hole0" />

    <ImageButton
        android:id="@+id/imgBtn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:background="@android:color/transparent"
        android:src="@drawable/hole0" />

    <ImageButton
        android:id="@+id/imgBtn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:background="@android:color/transparent"
        android:src="@drawable/hole0" />

    <ImageButton
        android:id="@+id/imgBtn3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:background="@android:color/transparent"
        android:src="@drawable/hole0" />

    <ImageButton
        android:id="@+id/imgBtn4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:background="@android:color/transparent"
        android:src="@drawable/hole0" />

    <ImageButton
        android:id="@+id/imgBtn5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:background="@android:color/transparent"
        android:src="@drawable/hole0" />
</LinearLayout>

Upvotes: 1

Views: 1503

Answers (2)

callOfCode
callOfCode

Reputation: 1026

In your case I would use FrameLayout. One of it's purposes is ability to stack items on each other. Just google it and you will find plenty of tutorials.

Upvotes: 1

bkurzius
bkurzius

Reputation: 4068

What about wrapping your LinearLayout in a FrameLayout or RelativeLayout and then place the image above it?

Upvotes: 0

Related Questions