2017-10-07 7 views
1

と一致した私の(関連)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> 

私は上記のライン上のエラーを取得しています。あなたが注記されている場合ID /要素は右のそれを下回る座って見ることができるのでとして起こっている理由は、私はよく分からない

No resource found that matches the given name (at 'layout_below' with value '@id/whiteBackground').

私に言っています。そして、下にある他の2つのボタンも同じように使用してください。layout_below="@id/whiteBackground"があり、エラーはありません。それはちょうど1行です。

誰かが私に何が起こっているか教えてもらえれば、それは大歓迎です。

おかげ

+1

その後たびにあなたがそれを初めて参照(上から下に読みを)id' @ + '試してみてください、と' id' @。 – stkent

+0

どうもありがとうございます。私はそれがちょうどrelativelayoutsで起こる何かだと思います。 –

+0

これはもっと一般的に 'RelativeLayout'sで起こりますが、それは彼らにとってユニークではありません! – stkent

答えて

2

あなたは、私はそれはあなたを願っていますことを願っています

layout_below="@+id/whiteBackground" 

layout_below="@id/whiteBackground" 

を変更することができます!

1

あなたのコードでこれを試してください。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<Button 
    android:id="@+id/menu_button" 
    android:layout_width="50dp" 
    android:layout_height="0dp" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@id/whiteBackground" 
    android:layout_centerInParent="true" 
    android:layout_marginBottom="60dp" 
    android:layout_marginTop="8dp" 
    android:background="@mipmap/ic_launcher" 
    android:onClick="myOnClickMethod" /> 

<ImageView 
    android:id="@+id/whiteBackground" 
    android:layout_width="350dp" 
    android:layout_height="350dp" 
    android:layout_below="@+id/image_text_editor" 
    android:layout_centerInParent="true" 
    android:background="@drawable/myrect" 
    android:contentDescription="@string/white_background" 
    android:elevation="15dp" 
    android:tag="white" 
    android:visibility="visible" /> 

<Button 
    android:id="@+id/text_size_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/whiteBackground" 
    android:layout_marginBottom="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginTop="8dp" 
    android:layout_toLeftOf="@id/menu_button" 
    android:onClick="SizeChange" 
    android:text="@string/size" 
    android:visibility="visible" /> 

<Button 
    android:id="@+id/move_Button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/whiteBackground" 
    android:layout_margin="8dp" 
    android:layout_toRightOf="@id/menu_button" 
    android:onClick="MoveChange" 
    android:text="MOVE" /> 
</RelativeLayout> 
  • XMLコードのルートに高さと幅を追加します。

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 
    
  • idが存在することを確認してください。

    android:layout_below="@+id/image_text_editor" 
    
関連する問題