Android 相对布局中的循环依赖项错误。

Android 相对布局中的循环依赖项错误。,android,android-layout,runtime-error,android-relativelayout,Android,Android Layout,Runtime Error,Android Relativelayout,我试图在一个相对布局中使用自定义按钮,但在runtimr上我遇到了这个来自相对布局的循环依赖错误,有人能指导我吗?当我使用线性布局(代码修改后)时,它工作得很好 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width=

我试图在一个相对布局中使用自定义按钮,但在runtimr上我遇到了这个来自相对布局的循环依赖错误,有人能指导我吗?当我使用线性布局(代码修改后)时,它工作得很好

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

<ImageView
    android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/logo2" />

<Button
    android:id="@+id/playBtn"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_above="@+id/settingsBtn"
    android:layout_below="@id/logo"
    android:background="@drawable/button_selector"
    android:paddingBottom="5dip"
    android:paddingTop="5dip"
    android:text="Play"
    android:textColor="#ffffff" />

<Button
    android:id="@id/settingsBtn"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_above="@+id/rulesBtn"
    android:layout_below="@id/playBtn"
    android:background="@drawable/button_selector"
    android:paddingBottom="5dip"
    android:paddingTop="5dip"
    android:text="Settings"
    android:textColor="#ffffff" />

<Button
    android:id="@id/rulesBtn"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_above="@+id/exitBtn"
    android:layout_below="@id/settingsBtn"
    android:background="@drawable/button_selector"
    android:paddingBottom="5dip"
    android:paddingTop="5dip"
    android:text="Rules"
    android:textColor="#ffffff" />

<Button
    android:id="@id/exitBtn"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_below="@id/rulesBtn"
    android:background="@drawable/button_selector"
    android:paddingBottom="5dip"
    android:paddingTop="5dip"
    android:text="Exit"
    android:textColor="#ffffff" />
</RelativeLayout>

由于位于另一个按钮上方的按钮意味着第二个按钮位于第一个按钮下方,因此无需同时指定这两个按钮

删除:

android:layout_below="@id/playBtn"


RelativeLayout
使用上面、下面、toLeftOf和toRightOf之类的内容。你可以逻辑地说“X是Y的左边;Y是X的右边”。这是有道理的,但它并没有说一个在哪里结束,另一个在哪里开始。当您这样做时,解析器不知道如何布置值。所以,你只要说“X是Y的左边”。然后它将首先布局Y(在不考虑X的情况下占用配置为占用的任何空间),并将X放在它的左侧

简短回答:使用上面的
layout_
或下面的
layout_
来定义关系,但决不能同时使用两者

 android:layout_below="@id/settingsBtn"
android:layout_below="@id/rulesBtn"