网站图片水印,网站建设流程代理商,网页程序编写,推广自身网站Android开发中遇到的奇葩问题之一#xff1a;java.lang.NullPointerException#xff0c;java.lang.RuntimeException:Binary XML file line #2: You must supply a layout_height attribute inflate#xff0c;遇到这个问题说明你在非主流上测试#xff0c;或者说是在部分… Android开发中遇到的奇葩问题之一java.lang.NullPointerExceptionjava.lang.RuntimeException:Binary XML file line #2: You must supply a layout_height attribute inflate 遇到这个问题说明你在非主流上测试或者说是在部分模拟器上测试或者是在写布局文件的时候少了什么东西比如是写成这样的Button xmlns:androidhttp//schemas.android.com/apk/res/android android:layout_width30dp android:layout_height10dp android:texttest /那你只是需要改成这样的 (区别是http后面少了冒号哈哈哈哈哈哈)Button xmlns:androidhttp://schemas.android.com/apk/res/android android:layout_width30dp android:layout_height10dp android:texttest / 或者这样的错误LinearLayoutxmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_width20dpandroid:layout_height5dpandroid:idid/tablerow01 其他的遇到的情况是如果不是在include的时候出现的那么请关闭浏览器标签重新找解决方案否则请听我重现我的bug。 情景重现我在添加布局的时候是这么写的include android:idid/test layoutlayout/activity_base/include然后在大部分的测试机上跑起来都是正常的当用到OPPO A31 手机的时候报错错误就是以上显示的。这个时候只需要这只include的width和height属性就好就像这样include android:idid/test layoutlayout/activity_base android:layout_widthmatch_parent android:layout_height30dp/includePS 如果写成如下情况也还是原来的错误include android:idid/test layoutlayout/activity_base android:layout_widthmatch_parent android:layout_heightdimen/fab_margin/include 这个错误具体的原理我百思不得其解如有解决希望多交流PoarryScriptgmail.com 转载于:https://blog.51cto.com/poarry/1737778