Al.
Al.

Reputation: 13

Make imageview appear above Gallery

I have a Gallery widget and 2 imageviews, one on the left of the screen and one on the right. I want the imageview and gallery to stay on the same line, but if there is an overlap, the imageview's z-index should be higher then the gallery's.

The problem is the imageview appears underneath the gallery item. I've had a look in the android doc, but can't find the solution. My XML file is below (For some reason, the opening Root relative layout's opening and closing tag isn't showing up):

<ImageView
    android:id="@+id/greenarrow_right"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/green_arrow_right"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dip"
    android:layout_marginTop="10dip"
/>  

<ImageView
    android:id="@+id/greenarrow_left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/green_arrow_left"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="10dip"
    android:layout_marginTop="10dip"
/>  
<Gallery 
    android:id="@+id/gallery"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:spacing="3dip"         
/>

  <!-- more elements here -->

Upvotes: 1

Views: 2020

Answers (2)

RickNotFred
RickNotFred

Reputation: 3401

Did you try ViewParent.BringChildToFront(myImageView) ?

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006584

The last child of the RelativeLayout will be on top. If your layout is as depicted above, that means the Gallery will be on top of the second ImageView. Change your XML and the RelativeLayout rules to make the second ImageView appear after the Gallery in the XML.

Upvotes: 2

Related Questions