我正在嘗試爲ListActivity
的每一行創建背景。我有兩個需要並排放置的背景圖片。有一個leftshopitem
圖像用作項目圖標的佔位符,以及用於寫入文本信息的rightshopitem
圖像。Android xml - 在相對佈局中覆蓋文本/圖像
基本上我想要以下屬性:我需要圖像圖標居中在leftshopitem
圖像上,我需要textViews顯示在rightshopitem
圖像上。
目前,我有這個代碼 - 我意識到這是錯誤的。背景圖像顯示正確對齊,但圖標和文本不正確。我想我的問題是,我怎樣才能使imageView成爲'父',以便我可以放置其他對象相對於它的位置。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/leftbackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/leftshopitem" />
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
/>
<ImageView
android:id="@+id/rightbackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/leftbackground"
android:src="@drawable/rightshopitem" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
>
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
/>
<TextView
android:id="@+id/weight"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="16sp"
/>
</LinearLayout>
</RelativeLayout>
任何線框卡扣? –