在修改了Android布局文件后,編譯出現Error parsing XML: not well-formed (invalid token)。
首先先排查xml文件的編碼格式是否為UTF-8, <?xml version="1.0" encoding="utf-8"?> ,注意,從別處copy的要留意編碼格式!
還有各個標簽是否有遺漏,把鼠標箭頭移到出錯誤的layout上 點擊鼠標右鍵選擇Source然后再選Format。
都沒有問題,結果發現報錯處(第9行):
1 <TextView 2 3 android:id="@+id/TetxView1" 4 5 android:layout_width="wrap_content" 6 7 android:layout_height=“wrap_content” 8 9 android:text=">31" 10 11 android:textSize="@dimen/text_size" 12 13 android:textColor="@color/text_color" 14 15 />
在控件屬性值里包含“>”或“<”,就會出錯,建議在代碼中賦值!