为什么我的标签没有正确关闭?

时间:2015-09-12 16:01:59

标签: android tags tagging

我有2天的Android体验...
这种布局中的标记有什么问题?
它说标签开始没有关闭,但我不必用/>关闭每个TextView,对吧?

教程人员说你最后只需要一个/>

<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">

<TextView
    android:text="Happy Birthday Mert"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
<TextView
    android:text="from cengiz"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/cake"
/>
</RelativeLayout>

2 个答案:

答案 0 :(得分:4)

xml中的每个标记都必须关闭。在你的情况下,必须像这样关闭textview。

<TextView
    android:text="from cengiz"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

或者像这样

<TextView
    android:text="from cengiz"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</TextView>

答案 1 :(得分:0)

I don't have to close every TextView with /> right?
当然,你必须

The tutorial guy said you need to put only one /> at the end?
我真的怀疑程序员会这么说。

<TextView
    android:text="Happy Birthday Mert"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
<TextView
    android:text="from cengiz"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

必须

<TextView
    android:text="Happy Birthday Mert"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
/>
<TextView
    android:text="from cengiz"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
/>
相关问题