2013-05-18 10 views
1

錯誤:根元素下列文件中的標記必須有良好的成形請幫助我新的機器人

<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" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".HelloActivity" > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/hello_world" 
</textview> 

+1

對於初學者來說,''缺少一個大寫字母'T',如果它之前的行不以'>結尾。另外,使用'',所以你不需要單獨的結束標籤。 –

+0

[如何修復錯誤:根元素之後的文檔中的標記必須格式良好](https://stackoverflow.com/questions/46355454/how-to-fix-error-the-markup-在這個文件中,遵循這個根元素必須) – kjhughes

回答

1

你忘了結束第一個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" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     tools:context=".HelloActivity" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/hello_world" /> 
    </RelativeLayout> 
-1

只需更換下面的代碼: -

<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/hello_world" 

有: -

<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/hello_world" /> 

如果一切正常,那麼請將此答案標記爲已接受。

+0

你在上面的代碼中做了什麼改變。 :P –

相關問題