【问题标题】:Multiple annotations found at this line在此行发现多个注释
【发布时间】:2014-03-19 20:38:57
【问题描述】:

在此行发现多个注释: - 错误:解析 XML 时出错:文档元素后出现垃圾 根元素之后的文档中的标记必须格式正确。

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.onyourcar.MainActivity"
        tools:ignore="MergeRootFrame" />

    <TextView
        android:id="@+id/hello"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world"
        tools:context=".MainActivity" />

【问题讨论】:

  • 请发布完整的 XML
  • 错误似乎不在您的文本视图中,请发布其余部分
  • 其实我是一个自学者,我想做的是创建一个新的id,这样我就可以看到对应用程序的影响。
  • 你关闭这个 FrameLayout 标签了吗?这是你的整个 xml 内容吗?
  • 是的,这是我的整个 xml

标签: android android-layout


【解决方案1】:

默认的texview是这样的

 <TextView
        android:id="@+id/theTextViewIdHere"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

并尝试使用相对/线性布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/hello"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

</RelativeLayout>

如果你想使用 FrameLayout 打谷歌示例代码

我对您的问题的第一个猜测是“工具:上下文”的最后一行尝试删除该行。如果这不起作用,请发布您的整个 XML 文件。

希望这会有所帮助。

【讨论】:

  • 如果我删除“tools:context”我有一个错误:文档中根元素后面的标记必须格式正确。
  • 我还建议您需要谷歌一下相对布局和线性布局之间的区别。
猜你喜欢
  • 2015-12-06
  • 1970-01-01
  • 1970-01-01
  • 2017-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-11
相关资源
最近更新 更多