gpt4 book ai didi

java - Include 指令未包含所需内容

转载 作者:行者123 更新时间:2023-12-01 04:49:25 25 4
gpt4 key购买 nike

嗨,我对 Android 编程非常陌生,我正在使用 include 标签。

我有一个名为 companylogo 的布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Logo Start-->
<ImageView android:src="@drawable/logo2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"/>
</LinearLayout>

和其他名为homepage的布局文件,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#ffffff">
<include layout="@layout/companylogo" />
</RelativeLayout>
</ScrollView>

但这不会将图像添加到主页布局中。

我什至尝试添加 android:layoutwidth/height 标签。不知道我在哪里犯了错误。

提前致谢。

最佳答案

实际上,当我们在代码中实现 xml 时,为了显示布局的效果,我们有时必须清理项目。

并尝试将layout_width和layout_height属性添加到include标记中。

尝试清理项目,如果仍然不起作用

关闭 Eclipse,然后再次打开它,就可以了。

有关更多信息,请查看此链接:

android include tag - invalid layout reference

Does Android XML Layout's 'include' Tag Really Work?

关于java - Include 指令未包含所需内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15240669/

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