2013-02-08 2 views
0

android:layout_...ImageView과 작동합니까? 사진에서 모든 10 개의 행이 서로 위에 있다는 것을 볼 수 있습니다. 즉, q2Image은 행을 삭제하고 다음 행에 별표를 표시하는 코드 android:layout_below="@/q1Image"을 허용하지 않습니다.android : ImageView가 작동하지 않는 layout_below

나는 뭔가를 놓치고 있습니까? 아니면 불가능한 것을하려고합니까? 그런

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="65" 
    android:fillViewport="true" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <ImageView 
      android:id="@+id/q1Image" 
      android:layout_width="10dp" 
      android:layout_height="10dp" /> 

     <TextView 
      android:id="@+id/q1Question" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/q1Image" /> 

     <TextView 
      android:id="@+id/q1Answer" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/q1Question" /> 

     <TextView 
      android:id="@+id/q1Verse" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/q1Answer" /> 

     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp"  
      android:background="#C2BEBF" /> 

     <ImageView 
      android:id="@+id/q2Image" 
      android:layout_width="10dp" 
      android:layout_height="10dp" 
      android:layout_below="@id/q1Image" /> 

     <TextView 
      android:id="@+id/q2Question" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/q2Image" /> 

     <TextView 
      android:id="@+id/q2Answer" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/q2Question" /> 

     <TextView 
      android:id="@+id/q2Verse" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/q2Answer" /> 

     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp"  
      android:background="#C2BEBF" /> 
//Above code is first 2 rows. There are 10 rows total but I removed the code for rows 3-10 for this post. 

enter image description here

+0

자세한 내용은이 질문을 확인하십시오. http://stackoverflow.com/questions/5025910/difference-between-and-id-in-android –

+0

두 가지 방법으로 읽고 결과를 모두 얻었습니다. . – Matt

+0

이클립스에서 그래픽 레이아웃으로 이동하여 대신 마우스를 사용하여 코드를 작성하십시오. – Pragnani

답변

0

참조하는 아이디의 항상 작동하지 않습니다. "@id"를 "@ + id"로 대체하십시오. 예 :

android:layout_below="@+id/q1Image" 
+0

모든 인스턴스가''''''''''''를 추가하도록 변경되었지만 결과는 같습니다. – Matt

+0

깨끗한 상태로 만들어보세요. –

+0

나는 동일한 결과로 청소하고 재건했다. – Matt

1

시도는 코드에서 ID를 액세스하는 방법이 올바른지

@+id 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" > 

     <!-- here the columns --> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" > 

     <!-- here the columns --> 
    </LinearLayout> 
    . 
    . 

</LinearLayout> 
+0

모든 인스턴스가''''''''''''를 추가하도록 변경되었지만 결과는 같습니다. – Matt

+0

문제에 대한 화면보기가 있었습니까? 나는 더 간단한 방법이라고 생각한다. –

+0

화면보기 란 무엇을 의미 하는가? – Matt

0

확인해야 @ 및 ID와 모든 사이에 + 넣어. "@ + id"는 id를 선언하는 데 사용됩니다. 선언 다음에 나오는 모든 참조는 "@id"여야합니다. TextViews에서도 동일한 문제가 있습니까? TextViews layout_below 속성을 설정해야한다고 생각합니다. 왜냐하면 텍스트가 UI에서 겹쳐서 표시되기 때문입니다. 예 :

<TextView 
     android:id="@+id/q2Question" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below = "@id/q1Question" 
     android:layout_toRightOf="@id/q2Image" /> 

relativeLayout은 layout_below를 지정하지 않으면 다른보기 아래에보기를 배치하지 않습니다. 따라서 TextViews가 겹쳐서 보입니다.

관련 문제