tabhost切换标签:Log中出现You must supply a layout_width attribute的解决方法
2015-04-16 10:45
435 查看
谷歌、百度该问题,发现,除非是真的忘记添加layout_height或者layout_width属性值,对于布局文件没有语法问题但又难以发现问题所在的情况,从自己的经历和一个帖子的说明看到,该错误多半是由于忘记在XML中添加某个属性的长度值。
我遇到的情况,在布局中有如下的长度引用:
android:layout_marginTop ="@dimen/dial_number_bn_top"
但是并没有在对应dpi文件夹的dimens.xml中定义该属性值,因此出错。另外,缺少一些图片资源可能也会引起该错误。
http://blog.sina.com.cn/s/blog_76721b120101ai5j.html
另:
今天在编辑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" 这一句,就会报错。具体原因待查中。
我遇到的情况,在布局中有如下的长度引用:
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" 这一句,就会报错。具体原因待查中。
相关文章推荐
- Log中出现You must supply a layout_width attribute的解决方法
- You must supply a layout_width attribute.解决办法
- You must supply a layout_width attribute. 错误解决
- You must supply a layout_width attribute 错误解决办法
- You must supply a layout_width attribute. 错误解决
- You must supply a layout_width attribute的错误原因及解决办法
- 即使这么忙,还是要记录下这个AndroidStudio的坑:Binary XML file line #20: You must supply a layout_width attribute.
- You must supply a layout_width layout_width attribute 解决办法
- [置顶] Android无法启动AVD解决方法出现"The connection to adb is down...You must restart adb and Eclipse."
- 解决Android的DL插件三星手机报错Binary XML file line #31:You must supply a layout_height attribute.
- Android -Logcat:you must supply a layout_width attribute
- 错误:Binary XML file line #23: You must supply a layout_width attribute.
- You must supply a layout_width layout_width attribute 错误
- Binary XML file line #11: You must supply a layout_width attribute
- 关于Androidstudio中NavigationView出现的问题(No resource identifier found for attribute 'headerLayout' )及解决方法
- MySQL5.1主从同步出现Relay log read failure错误解决方法
- 【layout】Binary XML file line #23: You must supply a layout_width attribute.
- sudo出现sudo:must be setuid root问题的解决方法
- 出现错误 Element type "LinearLayout" must be followed by either attribute specification,">"or"/>"的解决办法
- 标签控件中显示对话框出现的问题及解决方法