日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Binary XML file line #2: You must supply a layout_height attribute inflate

發布時間:2025/3/8 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Binary XML file line #2: You must supply a layout_height attribute inflate 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Android開發中遇到的奇葩問題之一:

java.lang.NullPointerException,java.lang.RuntimeException:Binary XML file line #2: You must supply a layout_height attribute? inflate,

?

遇到這個問題說明你在非主流上測試,或者說是在部分模擬器上測試,或者是在寫布局文件的時候少了什么東西,比如是寫成這樣的:


<Button xmlns:android="http//schemas.android.com/apk/res/android"
???
android:layout_width="30dp"
???
android:layout_height="10dp"
???
android:text="test" />

那你只是需要改成這樣的 (區別是http后面少了冒號哈哈哈哈哈哈)

<Button xmlns:android="http://schemas.android.com/apk/res/android"
???
android:layout_width="30dp"
???
android:layout_height="10dp"
???
android:text="test" />

?

或者這樣的錯誤

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android">
android:layout_width="20dp"
android:layout_height="5dp"
android:id="@+id/tablerow01">

?

其他的遇到的情況是如果不是在include的時候出現的那么請關閉瀏覽器標簽,重新找解決方案,否則請聽我重現我的bug

?

情景重現:我在添加布局的時候是這么寫的

<include
???
android:id="@+id/test"
???
layout="@layout/activity_base"></include>

然后,在大部分的測試機上跑起來都是正常的,當用到OPPO A31 手機的時候報錯,錯誤就是以上顯示的。

這個時候只需要這只includewidthheight屬性就好就像這樣

<include
???
android:id="@+id/test"
???
layout="@layout/activity_base"
???
android:layout_width="match_parent"
???
android:layout_height="30dp"></include>

PS :如果寫成如下情況也還是原來的錯誤)

<include
???
android:id="@+id/test"
???
layout="@layout/activity_base"
???
android:layout_width="match_parent"
???
android:layout_height="@dimen/fab_margin"></include>

?

這個錯誤具體的原理我百思不得其解,如有解決希望多交流(PoarryScript@gmail.com


轉載于:https://blog.51cto.com/poarry/1737778

總結

以上是生活随笔為你收集整理的Binary XML file line #2: You must supply a layout_height attribute inflate的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。