使图像视图显示在图库上方

时间:2010-01-24 23:17:13

标签: android layout view gallery z-index

我有一个Gallery小部件和2个图像视图,一个位于屏幕左侧,另一个位于右侧。我希望imageview和gallery保持在同一条线上,但如果有重叠,则imageview的z-index应该高于gallery的。

问题是图像视图出现在图库项目下方。我已经看过android doc,但找不到解决方案。我的XML文件在下面(出于某种原因,开放的Root相对布局的开始和结束标记没有显示):

<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 -->

2 个答案:

答案 0 :(得分:2)

RelativeLayout的最后一个孩子将位于最前面。如果您的布局如上所示,则表示Gallery将位于第二个ImageView之上。更改您的XML和RelativeLayout规则,使第二个ImageView出现在XML中的Gallery之后。

答案 1 :(得分:0)

你试过ViewParent.BringChildToFront(myImageView)吗?

相关问题