【发布时间】:2013-01-15 03:29:13
【问题描述】:
在我的项目中,我创建了一个全局标题布局 global_header.xml,并通过 <include layout="@layout/global_header.xml"> 在我的所有布局 XML 文件中使用它。
这个方法我以前用过,目前在这个项目中使用。我的问题是我的布局包含以下内容:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF" >
<include layout="@layout/global_header" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/global_header">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</ScrollView>
</RelativeLayout>
global_header.xml的内容:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/global_header"
android:layout_width="fill_parent"
android:layout_height="60sp"
android:layout_alignParentTop="true"
android:background="#FFDDDDDD" >
<ImageView
android:id="@+id/global_header_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5sp"
android:layout_marginTop="5sp"
android:adjustViewBounds="true"
android:src="@drawable/header" />
<View
android:layout_width="fill_parent"
android:layout_height="1sp"
android:layout_alignParentBottom="true"
android:background="#FF000000" />
</RelativeLayout>
我在android:layout_below="@global/header" 上收到一条错误消息:
错误:错误:未找到与给定名称匹配的资源(位于“layout_below”,值为“@global/header”)。
我已经在项目的其他布局中使用了包含,它可以正常工作,但无论出于何种原因,此布局文件都不会像所有其他布局一样从标题加载 ID。
即使我确信一旦在设备上运行它会发现它没有问题,该项目也不会出现此错误,是否有其他人遇到此问题?有解决方案/解决方法吗?
非常感谢任何和所有帮助。
【问题讨论】:
标签: android xml layout include