android - 在relativelayout中关联2个小部件时出错

标签 android android-relativelayout

我正在尝试关联小部件,我编写的代码如下:

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="90dp"
        android:background="@drawable/ad1"
        android:orientation="horizontal" >

        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/ad1"
        android:orientation="horizontal"
        android:layout_toStartOf="@id/bt_menu" > // here there is error !!!!

        <EditText
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:hint="Menu "
        android:inputType="textVisiblePassword"/>
            </RelativeLayout>

        <ImageButton 
                 android:id="@+id/bt_menu" 
                 android:layout_width="50dp"
                 android:layout_height="50dp" 
                 android:layout_alignParentRight="true"
                 android:layout_alignParentTop="true"
                 android:background="@android:color/transparent"
                 android:scaleType="fitCenter" 
                 android:src="@drawable/menu5"
                 android:onClick="menu_onclick"/>
        </RelativeLayout>

我在这一行有一个错误:

android:layout_toStartOf="@id/bt_menu"

错误是:找不到与给定名称匹配的资源(在“layout_toStartOf”处,值为“@id/bt_menu”)

谁能帮帮我!!!

预先感谢您..Fadel。

最佳答案

更改为

 android:layout_toStartOf="@+id/bt_menu" >

添加“+”

如果它位于您引用的 layout 之前,那么在保存它之前 Eclipse 似乎并不知道它。运行一次后,您应该能够将其更改回原来的状态。但我不知道离开它会有什么伤害。如果我使用诸如 layout_below 之类的属性,但将其放在 View 之前,我会这样做,我希望它相对于或类似的东西,但我只是保留它。

可能有更好的方法在 Eclipse 或您使用的任何编辑器中处理此问题,但据我所知,这是最简单的,我不知道它会产生任何不良影响。

关于android - 在relativelayout中关联2个小部件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19190179/

相关文章:

java - android:如何在哈希表中加载sqlite数据

android - Firebase android分页

android - RelativeLayout如何给布局权重?

android - 如何将 View 放置在特定位置(x、y 坐标)

android - TextView 不显示在 RelativeLayout 中

android - 布局占用超过预期

java - 在 ArrayAdapter 中设置 OnClickListener

Android在 fragment 内的工具栏中添加图标

android - 如何在签名过程中获取android签名的 map key ?

android - RelativeLayout 覆盖 RelativeLayout 组件中声明的组件