這裏是我的(相關)XML代碼:沒有資源發現匹配給定名稱
<RelativeLayout
<Button
android:id="@+id/menu_button"
android:layout_width="50dp"
android:layout_height="0dp"
android:layout_marginBottom="60dp"
android:layout_marginTop="8dp"
android:background="@mipmap/ic_launcher"
android:onClick="myOnClickMethod"
android:layout_below="@id/whiteBackground" <---- ERROR HERE
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"/>
<ImageView
android:id="@+id/whiteBackground" <---- HERE IS THE ID
android:layout_width="350dp"
android:layout_height="350dp"
android:contentDescription="@string/white_background"
android:tag="white"
android:visibility="visible"
android:background="@drawable/myrect"
android:elevation="15dp"
android:layout_below="@id/image_text_editor"
android:layout_centerInParent="true"/>
<Button
android:id="@+id/text_size_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/size"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:visibility="visible"
android:onClick="SizeChange"
android:layout_below="@id/whiteBackground" <---- ALSO BEING USED HERE (NO ERROR)
android:layout_toLeftOf="@id/menu_button"/>
<Button
android:id="@+id/move_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/menu_button"
android:layout_below="@id/whiteBackground" <----ALSO BEING USED HERE (NO ERROR)
android:layout_margin="8dp"
android:onClick="MoveChange"
android:text="MOVE"/>
</RelativeLayout>
我的注意的行收到一個錯誤之上。它告訴我
No resource found that matches the given name (at 'layout_below' with value '@id/whiteBackground').
我不知道爲什麼會這樣,因爲你可以看到ID /元素坐在下方注意的地方。正如你可以看到下面的其他2個按鈕也使用相同的layout_below="@id/whiteBackground"
,並且沒有錯誤。這只是一條線。
如果有人能告訴我發生了什麼事情,那將不勝感激。
感謝
嘗試'@ + id'你第一次引用它(讀從上到下)和'@ id'之後每次。 – stkent
非常感謝你@stkent我猜這只是發生在相關佈局中的東西 –
它發生在RelativeLayout的更常見的情況是,但它不是唯一的! – stkent