2011-08-28 4 views
0

TextView 아래의 이미지를 RelativeLayout에 위치 시키려고하는데 작동하지 않습니다. 내가 android:layout_below을 사용하여 위치를 설정할 때. 이것은 내 XML입니다Android의 상대 레이아웃에서 이미지보기의 위치를 ​​설정하려면 어떻게해야합니까?

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:background="#ccc" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<TextView 
android:id="@+id/app_details_1" 
android:text="@string/app_details_1" 
android:textColor="#347" 
android:gravity="center" 
android:textSize="9pt" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
/> 

<ImageView 
android:id="@+id/logo" 
android:src="@drawable/secs" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:layout_below="@+id/appdetails_1" <!-- I'm setting it here --> 
/> 

</RelativeLayout> 

대신 화면의 왼쪽 상단에 이미지가 배치됩니다. 어떻게 배치합니까? layout_below 위치 코드가 잘못 되었습니까?

답변

4

XML에 실수가 있습니다.

android:layout_below="@id/app_details_1" 
+1

완전히 설명하려면 :'+ id'는이 ID를 생성해야하는 바로 가기입니다. 기존 ID를 참조 할 때, 그것은 단지'id'입니다. 이것에 관한 공식 문서 : http://developer.android.com/guide/topics/ui/declaring-layout.html#id –

+0

또한 'app_details_1' 대신'appdetails_1' 오타가 있습니다 – Ronnie

+1

@ user7777777777 예, 유일한 실수입니다. 더하기 부호는 오류가 아닙니다. – Michael

0

그것은 확인을해야 될 수 있지만 먼저 텍스트 뷰에 대한 layout_alignParentTop = "true"로 사용하여 확인 텍스트 뷰가 상부에 위치되어 있는지 확인하고 트릭을 수행합니다 있는지 확인하기 위해 시도해야합니다.

관련 문제