谷歌、百度该问题,发现,除非是真的忘记添加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=""
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" 这一句,就会报错。具体原因待查中。

tabhost切换标签:Log中出现You must supply a layout_width attribute的解决方法的更多相关文章

  1. Android Error:You must supply a layout_width attribute……

    出现这种情况的可能原因目前本人碰到的有: 1:在xml文件中某个属性名或者属性值写错,请务必仔细检查你有没有写错某个拼写. 2:当你在,比如TextView中,没有声明layout_width,经测试 ...

  2. You must supply a layout_width attribute的错误原因及解决办法

    学习android的过程中,尝试新功能,结果出现了这个一个error: 05-21 15:38:52.745: E/AndroidRuntime(17608): java.lang.RuntimeEx ...

  3. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  4. 关于真机调试DDMS中的data文件夹打不开的解决方法

    关于真机调试DDMS中的data文件夹打不开的解决方法 今天在开发的时候需要导出程序中的数据库文件查看数据,数据库文件默认就在/data/data/应用包名/databases/数据库名 这个路径下, ...

  5. Node.js中针对中文的查找和替换无效的解决方法

    Node.js中针对中文的查找和替换无效的解决方法.   //tags的值: tag,测试,帖子 var pos1 = tags.indexOf("测"); //这里返回-1 ta ...

  6. SecureCRT中某些命令提示符下按Backspace显示^H的解决方法

    SecureCRT中某些命令提示符下按Backspace显示^H的解决方法 安装了Apache Derby数据库服务器之后,使用ij客户端去连接derby服务端,可是在ij中输入命令的时候,每当输入错 ...

  7. C语言中关于POW在不同状态下四舍五入的解决方法

    这是今天作业中的一个代码: #include <stdio.h>#include<math.h>int main(){ printf("请输入一个整数:") ...

  8. php中url传递中文字符,特殊危险字符的解决方法

    php中的urldecode,base64_encode函数然后再结合自己写的替换函数来进行安全传递url中文字符,特殊危险字符. 需要在url中传递中文字符或是其它的html等特殊字符,似乎总会有各 ...

  9. MFC中cannot find the definition (implementation) of this function 解决方法

    问题:使用vc6 在点击左侧class view中的一个方法实现时出现下面错误:    cannot find the definition (implementation) of this func ...

随机推荐

  1. 驱动之module_init/module_exit

    在前面helloworld的编写里面,我们使用了两个宏分别是module_init和module_exit,这里分析下为什么使用这两个宏. 在写模块的时候有两个特殊的函数,分别是init_module ...

  2. winform中利用反射实现泛型数据访问对象基类(1)

    考虑到软件使用在客户端,同时想简化代码的实现,就写了一个泛型的数据访问对象基类,并不是特别健全,按道理应该参数化的方式实现insert和update,暂未使用参数化,抽时间改进. /// <su ...

  3. CentOS 修改线程数限制等(limits.conf)

    修改/etc/security/limits.conf,例如启动程序的用户为webadmin,则添加以下配置: webadmin - nofile 65536 webadmin - nproc 655 ...

  4. WebForm跨页面传值---内置对象

    一.Response Response - 响应请求对象 string path = "Default2.aspx": (1)Response.Redirect(path); -- ...

  5. Eclipse / android studio 添加第三方jar包 步骤

    eclipse 将第三方包放到libs文件夹后并没有引用. 基本步骤分为3步,具体介绍如下: 打开自己的Eclipse,在自己的Android工程上名上右键->Build Path ->C ...

  6. 【CSS】最全的CSS浏览器兼容问题

    CSS对浏览器的兼容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并 整理了一下.对于web2.0的过度,请尽量用xhtml ...

  7. 安装 slowhttptest ddos攻击软件

    kali:apt-get install slowhttptest

  8. Messages消息处理

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  9. ServiceStack.OrmLite 学习笔记3 建表

    创建表 前一篇忘记写创建表了,这里补上.(其实前一篇也有那么一点) 建议安装源码里的t4模板看看效果先. public 的属性才有效 在表被创建或者删除的时候执行sql语句 [PostCreateTa ...

  10. Android内存泄露测试

    Android性能测试过程中的一些常用命令: CPU: adb shell top -n | grep "+PackageName 内存: adb shell dumpsys meminfo ...