2016-04-21 59 views
0

如何在我的按鈕中將「<」和「>」設置爲文本?Android。 Gradle構建錯誤:解析XML時出錯:格式不正確(無效標記)

我的XML:

<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text=">" 
     android:id="@+id/button" /> 

搖籃建立自己的錯誤: 錯誤:(59)錯誤解析XML:沒有很好地形成(標記無效)

+0

嘗試'android:text =「\>」'。 –

+0

@RaphaelTeyssandier我嘗試這個並清除&重建項目,但問題仍然存在:( – Mikhail

回答

3

由於該文件是XML,你需要正確escape屬性值中的大於字符:

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="&gt;" 
    android:id="@+id/button" /> 
+0

謝謝!我忘記了這一刻... – Mikhail

1

XML中的某些字符不能直接使用。這包括&,<>,它們必須由corresponding entities代替。因此,而不是

android:text=">" 

你必須寫:

android:text="&gt;" 
1

而是採用>直接使用&gt;代碼。 refere this doc 使用this生成代碼

相關問題