2016-01-16 116 views
1

每当我运行应用程序时,都会出现此错误。我尝试过所有在线解决方案,但都失败了。错误:(4)解析XML时出错:格式不正确(无效标记)

任何帮助?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 
    <TextView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="dishname" 
     android:id="@+id/item_name" 
     android:textSize="24dp" 
     android:textColor="#396fd1" 
     android:layout_alignParentTop="true" 
     android:layout_alignStart="@+id/item_type" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="price" 
     android:id="@+id/item_price" 
     android:textSize="16dp" 
     android:layout_below="@+id/item_name" 
     android:layout_toEndOf="@+id/item_name" 
     android:layout_marginStart="32dp" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="type" 
     android:id="@+id/item_type" 
     android:textSize="12dp" 
     android:layout_below="@+id/item_name" 
     android:layout_alignStart="@+id/item_nofingredients" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="#" 
     android:id="@+id/item_nofingredients" 
     android:textSize="12dp" 
     android:layout_below="@+id/item_type" 
     android:layout_alignParentStart="true" 
     android:layout_marginStart="15dp" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Ingredients" 
     android:id="@+id/textView5" 
     android:textSize="12dp" 
     android:layout_below="@+id/item_type" 
     android:layout_toEndOf="@+id/item_type" /> 
    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/deleteButton" 
     android:layout_alignBottom="@+id/item_price" 
     android:layout_alignParentEnd="true" 
     android:layout_marginEnd="19dp" 
     android:background="@android:color/transparent" 
     android:src="@android:drawable/ic_menu_delete"/> 
</RelativeLayout> 
+0

你缺少一个开放的''标签。 –

+0

@MohammedAoufZOUAG我在这个评论中写了代码的开头 – ghumdan16

+1

用完整的布局代码更新您的文章,而不是在评论中。这里很难阅读。 –

回答

1

我为你编辑。你可以复制它。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
    <TextView android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="dishname" 
       android:id="@+id/item_name" 
       android:textSize="24dp" 
       android:textColor="#396fd1" 
       android:layout_alignParentTop="true" 
       android:layout_alignStart="@+id/item_type" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="price" 
     android:id="@+id/item_price" 
     android:textSize="16dp" 
     android:layout_below="@+id/item_name" 
     android:layout_toEndOf="@+id/item_name" 
     android:layout_marginStart="32dp" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="type" 
     android:id="@+id/item_type" 
     android:textSize="12dp" 
     android:layout_below="@+id/item_name" 
     android:layout_alignStart="@+id/item_nofingredients" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="#" 
     android:id="@+id/item_nofingredients" 
     android:textSize="12dp" 
     android:layout_below="@+id/item_type" 
     android:layout_alignParentStart="true" 
     android:layout_marginStart="15dp" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Ingredients" 
     android:id="@+id/textView5" 
     android:textSize="12dp" 
     android:layout_below="@+id/item_type" 
     android:layout_toEndOf="@+id/item_type" /> 
    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/deleteButton" 
     android:layout_alignBottom="@+id/item_price" 
     android:layout_alignParentEnd="true" 
     android:layout_marginEnd="19dp" 
     android:background="@android:color/transparent" 
     android:src="@android:drawable/ic_menu_delete"/> 
</RelativeLayout> 
+0

谢谢,,,,我重新输入了一切,现在它正在工作。 Android Studio充满了我相信的错误。 – ghumdan16

2

您的XML 11隐形vertical tab characters,在列#4月底的第一个。垂直制表符在XML中不是有效的空白字符。

Android Studio不显示垂直制表符。你可以使用像Sublime Text这样的编辑器来查看它们。

相关问题