我写的这个xml文件保存没有错误,并且在eclipse的预览中准确显示了我的预期。但是如果有足够的时间(大约5-10分钟),在继续处理项目的其他部分(如实际的Java文件)之后,此文件会抛出错误。
它抱怨,因为我已经锚定到xml文件中下面进一步声明的视图。但我无法解决这个问题,因为所有3个主要部分都相互依赖。如果我改变它,它看起来并不好看。
我该如何解决这个问题?
<!-- The chat bubble -->
<RelativeLayout
android:id="@+id/chat_bubble_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<!-- The user's name above the chat bubble -->
<TextView
android:id="@+id/chat_bubble_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/chat_bubble_comment" ERROR HERE!!!!
android:layout_marginLeft="9dip"
android:textSize="12sp"
android:text="Username"
android:textColor="#88000000">
</TextView>
<TextView
android:id="@+id/chat_bubble_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/chat_bubble_username"
android:layout_toRightOf="@id/chat_bubble_profile_picture"
android:layout_margin="5dip"
android:background="@drawable/bubble_yellow"
android:paddingLeft="4dp"
android:text="Hello bubbles!"
android:textColor="@android:color/primary_text_light" />
<!-- The user's profile picture next to the chat bubble -->
<ImageView
android:id="@+id/chat_bubble_profile_picture"
android:layout_marginLeft="10dip"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#000000"
android:layout_alignTop="@id/chat_bubble_comment"
/>
</RelativeLayout>
答案 0 :(得分:1)
更改
android:layout_alignLeft="@id/chat_bubble_comment"
到
android:layout_alignLeft="=@+id/chat_bubble_comment"