安卓开发由于界面文件缺少layout_width属性程序闪退出错

报错信息如下:

Process: com.example.lxh1205509119.xiaoprinter, PID: 27636
          android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.lxh1205509119.xiaoprinter.GeneralItemLayout
          Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.example.lxh1205509119.xiaoprinter.GeneralItemLayout
          Caused by: java.lang.reflect.InvocationTargetException

由该提示可以看出问题出在GeneralItemLayout的xml布局文件里,接着往下看:

Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: You must supply a layout_width attribute.
Caused by: java.lang.UnsupportedOperationException: Binary XML file line #0: You must supply a layout_width attribute.

由上面的错误信息可知由于在xml文件中缺少了layout_width属性值,打开GeneralItemLayout对应的布局文件,搜索layout_width字段,检查每隔控件是否都有layout_width属性,最后发现在TextView控件中缺少该属性,虽然该处设置了width的权重值,但layout_width还是不能缺,设置成android:layout_width="0dp"之后问题解决。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lxh1205509119

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值