我有一个Gallery小部件和2个imageview,一个在屏幕左侧,一个在右侧。我希望imageview和gallery保持在同一行,但是如果存在重叠,则imageview的z索引应该比图库的高。

问题是imageview出现在图库项目的下方。我已经查看了android doc,但是找不到解决方案。我的XML文件在下面(由于某些原因,未显示开始根相对布局的开始和结束标记):

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

最佳答案

RelativeLayout的最后一个子项将位于顶部。如果您的布局如上所述,则意味着Gallery将位于第二个ImageView的顶部。更改XML和RelativeLayout规则,使第二个ImageView出现在XML中的Gallery之后。

关于android - 使imageview出现在Gallery上方,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2129337/

10-09 07:15
查看更多