【问题标题】:Why aren't my tags properly closed?为什么我的标签没有正确关闭?
【发布时间】:2015-09-12 16:01:59
【问题描述】:

我有 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>

【问题讨论】:

    标签: android tags tagging


    【解决方案1】:

    xml 中的每个标签都必须关闭。在您的情况下,两个文本视图都必须像这样关闭。

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

    【讨论】:

      【解决方案2】:

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

      The tutorial guy said you need to put only one /&gt; 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"
      />
      

      【讨论】:

        猜你喜欢
        • 2019-05-09
        • 1970-01-01
        • 2021-06-10
        • 1970-01-01
        • 2016-04-15
        • 2014-07-16
        • 2018-03-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多