! 错误.文件名必须以xml结尾



我是一个初级开发人员。我已经谷歌这个问题,并在stackoverflow搜索。虽然有一些类似的问题回答了我的具体问题。下面是得到这个错误

的代码
<?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="wrap_content"
    android:layout_height="wrap_content"
    tools:context="com.example.android.happy18thbirthdayzane.MainActivity">

         <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/ImageView"
        android:background="@drawable/black"
        />
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="150dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Happy 18th Birthday!"
        android:textStyle="bold"
        android:textColor="#d3a625"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        />
    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="150dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Dear Zane"
        android:textStyle="bold"
        android:textColor="#d3a625"
        android:layout_centerHorizontal="true"
        android:inputType="text" />
</RelativeLayout>

因为资源文件没有以.xml结尾

可能是这个ImageView

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/ImageView"
    android:background="@drawable/black"
    />

导致此问题。

确保你的可绘制文件black命名为black.xml而不仅仅是black.

最新更新