【发布时间】:2018-03-04 18:57:28
【问题描述】:
我正在尝试根据用户在GameView 中的点击位置显示ImageView。我在android:layout_height="300dp" 上收到错误消息"Error:(15) error: not well-formed (invalid token)." GameView extends ViewGroup。我为GameView 实现了onMeasure、onLayout 和onDraw。
悬停在这些行的末尾会显示以下错误提示:
<com.example.GameView -- 多个根标签
android:layout_height="300dp" -- 标签开始没有关闭
<ImageView -- 多个根标签
<com.example.GameView> -- 意外令牌
</LinearLayout> -- 意外令牌
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
<com.example.GameView
android:layout_width="match_parent"
android:layout_height="300dp"
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</com.example.GameView>
</LinearLayout>
【问题讨论】:
-
这是您的确切布局吗?布局中包含错误。请使用您所拥有的确切布局更新您的问题。
-
为什么把
放在 里面? -
@ReazMurshed 是的,这是准确的布局。我已经用悬停时的确切错误更新了它
-
@MeosCoder 根据用户在
GameView中点击的位置,ImageView应该会出现