Android 编译错误——布局 Error parsing XML: not well-formed (invalid token)


在修改了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    />

 

在控件属性值里包含“>”或“<”,就会出错,建议在代码中赋值!

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM