Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基本XML/Android代码失败,不确定原因:包含代码和错误_Android_Xml_Debugging - Fatal编程技术网

基本XML/Android代码失败,不确定原因:包含代码和错误

基本XML/Android代码失败,不确定原因:包含代码和错误,android,xml,debugging,Android,Xml,Debugging,我编写了这个基本代码,但由于某些原因失败了,它工作正常,然后我尝试将图像添加为imageview,而不是添加到背景中。不幸的是,由于我试图研究和解决这个问题,结果只会使事情看起来更糟。此外,我尝试运行gradle调试,但它并没有告诉我太多 非常感谢您提供的任何建议。我是初学者,不怕批评 <?xml version="1.0" encoding="utf-8"?> </RelativeLayout xmlns:app="http://schemas.android.com

我编写了这个基本代码,但由于某些原因失败了,它工作正常,然后我尝试将图像添加为imageview,而不是添加到背景中。不幸的是,由于我试图研究和解决这个问题,结果只会使事情看起来更糟。此外,我尝试运行gradle调试,但它并没有告诉我太多

非常感谢您提供的任何建议。我是初学者,不怕批评

<?xml version="1.0" encoding="utf-8"?>
</RelativeLayout
    xmlns:app="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity"

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="From Lyla!"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:paddingRight="16dp"
        android:textSize="39sp"
        android:textColor="#ffffff"
        />

    <EditText
        android:id="@+id/editText"
        android:layout_alignParentTop= "true"
        android:paddingLeft= "16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:textSize="39sp"
        android:text="Happy Birthday, Ben!"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="50dp"
        android:textColor="#ffffff"/>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType= "center_crop"
        android:src= "@drawable/androidparty"
        />


</RelativeLayout>


您缺少RelativeLayout的结束“>”。您定义的XML无效

</RelativeLayout
xmlns:app="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">

用你的替换这个: 你错过了android:layout\u width,也错过了android:layout\u height

   <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"
    tools:context=".MainActivity">


这是相对布局中的打开和关闭标记问题。打开标记应具有:格式,而关闭标记应具有:格式。然后使用background属性,因为当您运行代码时,imageview将显示其余的项,因为它被设置为父项

打开的
RelativeLayout
标记有一些错误。删除
/
之前的
/
,在标记末尾添加一个
,并在其上指定一个
布局宽度和
布局高度。您试图说的格式似乎没有显示,介意再试一次吗?非常感谢你的帮助!很抱歉,您的格式应该是//列出您的文本视图或项目。您犯的错误是在开始标记中删除开始标记中的“/”,并记住为布局添加“高度”和“宽度”属性。我的错误是什么?顺便说一句,非常感谢你的帮助!这解决了我的问题