Daniel_cf 2013-01-31 06:24 采纳率: 100%
浏览 4801
已采纳

当用<include layout=“”>的时候报错:“No resource found”

在我的project中,我已经创建了一个全局的头layoutglobal_header.xml,而且我通过用<include layout="@layout/global_header.xml">把它用在了我所有的布局XML文件中。

之前我用过这个方法,现在我在这个project中用这个方法。我的问题的是我有一个layout用的下边的content:

<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="@global/header">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

global_header.xml的contents:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android: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"得到了一个错误:

error: Error: No resource found that matches the given name (at 'layout_below' with value '@global/header').

我之前在project的其他layout中用过,没有问题,但是不知道什么原因,这个layout文件不能像其他的layout一样从头文件处加载ID。
有这个问题的话project就不能build,尽管我知道一旦在设备中运行的话这不是个问题,还有人遇到过这个问题么?有什么解决办法么?

  • 写回答

2条回答 默认 最新

  • Billy_崔海斌 2013-01-31 08:44
    关注
    <include layout="@layout/global_header" android:id="@+global/header"/>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算