2011-11-07 4 views
0

ListActivity의 각 행에 대한 배경을 만들려고합니다. 나는 두 개의 배경 이미지를 나란히 놓아야한다. 항목 아이콘의 자리 표시 자 역할을하는 leftshopitem 이미지와 텍스트 정보를 덮어 쓸 이미지 rightshopitem이 있습니다.Android xml - 상대 레이아웃의 텍스트/이미지 오버레이

기본적으로 나는 다음과 같은 속성을 원합니다 : leftshopitem 이미지 위에 이미지 아이콘이 있어야하고 rightshopitem 이미지 위에 표시 할 textViews가 필요합니다.

현재로서는이 코드가 있습니다. 배경 이미지가 올바르게 정렬되어 표시되지만 아이콘과 텍스트는 올바르게 정렬되지 않습니다. 내 질문은, 어떻게 내가 그것의 위치에 상대적인 다른 개체를 배치 할 수 있도록 '부모'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> 
+0

모든 와이어 프레임 스냅? –

답변

1

당신은 너무에 android_layout_toLeftOf="@id/leftbackground", android_layout_toRightOf="@id/leftbackground"을 사용할 수 있습니다.

대신 android:align_parentLeft="true" 등을 사용하는 경우 필요에 따라 다른보기를 배치 할 수 있습니다.

android:background="@drawable/leftshopitem"을 사용하여 RelativeLayouts 중 하나에서 이미지를 역전으로 설정할 수도 있습니다 ("make imageView a 'parent'와 같은 종류).

+0

아, 나는 마지막 접근 방식으로 갈 것이라고 생각합니다. 레이아웃 영역을 이미지의 크기로만 만들 수 있다고 생각하지 않았습니다. 나는 그것이 '랩 - 컨텐트'가 의미하는 것임을 깨달았습니다. 그래서 나는 모두 설정되었습니다. 고마워요! :) – Wozza

+0

relativeLayout 및 linearLayout이 별도로 포함 된 LinearLayout을 만들어야했습니다. 이것은 배경 이미지가 rightshopitem을 추가하여 생성 된 영역을 채우기 위해 늘어나 기 때문입니다 – Wozza

관련 문제