[更新了,因为我显然还不能回答我自己的问题:这就像重新排序视图一样简单。我把TextView放在最后,指示layout_alignParentLeft="true",它做到了。]
我有一个典型的ListView项目描述,每行有文本和图像(3)。
我注意到行右侧的图像(id="@+id/browse_item_row_icon")被绘制在文本的上方。
虽然不是立即我想要的,我决定它实际上会工作,如果我可以有图像在文本后面,而不是在它上面。这将允许我在必要时显示更多的文本,并且覆盖部分图像不会影响可用性。
是否有一种方法来指示视图的上/下顺序?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/browse_item_row_text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginRight="48dip"
>
</TextView>
<ImageButton
android:id="@+id/browse_item_add_button"
android:background="@drawable/ic_add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
</ImageButton>
<ImageView
android:id="@+id/browse_item_to_submenu"
android:src="@drawable/expander_ic_minimized"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/browse_item_add_button" >
</ImageView>
<ImageView
android:id="@+id/browse_item_row_icon"
android:src="@drawable/ic_default_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/browse_item_to_submenu" >
</ImageView>
</RelativeLayout>
嗯,在你的情况下,如果你想在TextView后面的图像,你可以使用框架布局,试试这个。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton android:id="@+id/browse_item_add_button"
android:background="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
</ImageButton>
<ImageView android:id="@+id/browse_item_to_submenu"
android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toLeftOf="@id/browse_item_add_button">
</ImageView>
<ImageView android:id="@+id/browse_item_row_icon"
android:src="@drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toLeftOf="@id/browse_item_to_submenu">
</ImageView>
<TextView android:id="@+id/browse_item_row_text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24dp" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="ABCDEFGHIJKLMNOPQRSTUVWXYZ">
</TextView>
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
通过使用
使texview背景透明android:background="#0000"
我想它应该能胜任。