tabhost切换标签:Log中出现You must supply a layout_width attribute的解决方法
2023-09-14 08:57:52 时间
谷歌、百度该问题,发现,除非是真的忘记添加layout_height或者layout_width属性值,对于布局文件没有语法问题但又难以发现问题所在的情况,从自己的经历和一个帖子的说明看到,该错误多半是由于忘记在XML中添加某个属性的长度值。
我遇到的情况,在布局中有如下的长度引用:
android:layout_marginTop ="@dimen/dial_number_bn_top"
但是并没有在对应dpi文件夹的dimens.xml中定义该属性值,因此出错。另外,缺少一些图片资源可能也会引起该错误。
<resources> <!-- Default screen margins, per the Android Design guidelines. --> <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> </resources>
http://blog.sina.com.cn/s/blog_76721b120101ai5j.html
另:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="right" android:orientation="vertical" android:visibility="visible" > <LinearLayout android:layout_width="310dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:animateLayoutChanges="false" android:orientation="vertical" > <LinearLayout android:id="@+id/LinearLayout_dz" android:layout_width="match_parent" android:layout_height="37dp" android:orientation="horizontal" android:visibility="visible" > <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" /> </LinearLayout> </LinearLayout> </LinearLayout>
今天在编辑android布局文件时,后台提示以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pubproject/com.example.pubproject.MainActivity}: java.lang.RuntimeException: Binary XML
file line #23: You must supply a layout_width attribute.
经反复试验:原因是TextView只要缺少 android:layout_width="wrap_content" 这一句,就会报错。具体原因待查中。
相关文章
- MySQL启用Log记录技术深度剖析(mysql开启log)
- Oracle 等待事件 flashback log file sync 官方解释,作用,如何使用及优化方法
- Oracle 等待事件 log file sequential read 官方解释,作用,如何使用及优化方法
- Oracle 等待事件 log file switch (checkpoint incomplete) 官方解释,作用,如何使用及优化方法
- Oracle 等待事件 log file sync 官方解释,作用,如何使用及优化方法
- JSP application.log()方法:写入信息到Servlet的日志文件
- jQuery $.getJSON()方法的用法
- 字快速修改Linux服务器名字的方法(linux修改服务器名)
- 探索Linux:查看行数的方法(linux查看多少行)
- MySQL中使用MD5加密字段的方法及作用(mysqlmd5字段)
- Linux Log查看方法。(linux如何查看log)
- log深入了解Oracle Redo Log!(Oracle查看redo)
- :考勤机事件记录挖掘:MSSQL Log分析(考勤机mssql中log)
- 深入探索查看Redis服务器日志的方法(查看redis服务器日志)
- 探索Redis异常的模拟方法(如何模拟redis异常)
- 探索Oracle中Log位置的奥秘(oracle中log位置)
- 批处理自动解决Imail的Queuemgr服务挂起的方法
- Linuxtar压缩打包命令使用方法
- 让JavaScript拥有类似Lambda表达式编程能力的方法
- Android系统开发中log的使用方法及简单的原理
- 80端口被Pid为4的未知程序占用导致Apache不能启动的解决方法
- js调试工具console.log()方法查看js代码的执行情况