时-6ren"> 时-在我的项目中,我创建了一个全局标题布局 global_header.xml我通过使用 在我所有的布局 XML 文件中使用它. 这个方法我以前用过,目前正在这个项目中使用。我的问题是我的布局包含以下内-6ren">
gpt4 book ai didi

android - "No resource found"使用

转载 作者:数据小太阳 更新时间:2023-10-29 02:54:05 25 4
gpt4 key购买 nike

在我的项目中,我创建了一个全局标题布局 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" 上遇到错误说:

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

我已经在项目的其他布局中使用了 include 并且它可以正常工作,但无论出于何种原因,此布局文件不会像所有其他布局一样从标题中加载 ID。

尽管我确信一旦在设备上运行它会发现它不是问题,但该项目不会出现此错误,其他人是否遇到过此问题?有解决方案/解决方法吗?

非常感谢任何帮助。

最佳答案

试试这个,为包含布局和使用指定 id

 <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" android:id="@+id/header"/>

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/header">

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

关于android - "No resource found"使用<include layout="">时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14618852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com