Android 如何从include中引用id

Android 如何从include中引用id,android,android-layout,Android,Android Layout,问题是如何从include标记引用id 让我们看看这个例子: 我有这样的观点,我想在很多地方重复使用: <merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/

问题是如何从include标记引用id

让我们看看这个例子:

我有这样的观点,我想在很多地方重复使用:

<merge xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/first_el"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="Some txt 1" />
</merge>

关于

问题可能是因为layout\u alignRight属性中缺少“+”

我认为您可能需要更改android:layout\u alignRight=“@id/first\u el”


看看第一个XML,他定义了那个id,不应该在第二个XML中这么做。@Binyamin Sharet。。。安德罗·塞尔瓦是正确的。即使它被定义为id,您也必须再次使用
@+id/
来引用它。据我所知,在res/values/IDs.xml中定义id时使用
@id/
。有关更多信息,请参阅本文:有关更多信息,请参阅本文:
<RelativeLayout>
    <include layout="@layout/above_view"/>
    <TextView
        android:id="@+id/third_el"
        android:layout_alignRight="@id/first_el"
        android:layout_below="@id/first_el"
        android:text="Some txt 2" />
</RelativeLayout>
Description Resource Path Location Type error: Error: 
No resource found that matches the   given name (at 'layout_alignRight' with value '@id/first_el').
 android:layout_alignRight="@+id/first_el"