2012-01-02 36 views
1

現在,textview首先在垂直方向出現,接下來是imageview。我怎麼能這樣做,使textview疊加在XML的textview的頂部? textview具有比imageview更高的Z順序。將TextView直接放在XML上的Imageview頂部

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TableLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_margin="0px" 
android:padding="0px"> 
<TextView android:id="@+id/textItem" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:background="#AA000000" 
android:textColor="#ffffffff" 
android:textSize="22sp" 
android:text="Find Now" 
android:enabled="false" 
> 
</TextView> 
<ImageView 
android:id="@+id/myImageView0" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/bar_top"/> 

回答

2

一個可能的解決方案是刪除表的佈局和使用下面的代碼:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TextView android:id="@+id/textItem" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:background="#AA000000" 
android:textColor="#ffffffff" 
android:textSize="22sp" 
android:text="Find Now" 
android:enabled="false" 
> 
</TextView> 
<ImageView 
android:id="@+id/myImageView0" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@+id/textItem" 
android:src="@drawable/bar_top"/> 
</RelativeLayout> 

另一種解決辦法,如果你需要的表佈局一些其他的目的是使用framelayout,其內容將是textview和imageview,並將其添加爲桌面佈局的單元格

1

刪除TableLayout它應該是在彼此之上。你可以不是很容易被很多differen android:layout_...改變位置屬性