java.lang.RuntimeException:二进制XML您必须提供layout_width属性

时间:2012-03-16 16:05:03

标签: android xml layout

我必须盯着这个问题,看不到它,所以感谢任何帮助。

我的XML中有一个按钮声明:

<Button xmlns:android="http//schemas.android.com/apk/res/android"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:background="@drawable/key_bg"
        android:text="Q" />

当XML膨胀时,我收到上述错误并且应用程序崩溃。

我确定这个按钮导致问题,因为(1)错误中指示的行号正好是此按钮声明的行; (2)我在XML中有几个这样的,如果我注释掉这个,我得到相同的错误,行号指向具有相同声明的下一个按钮。

据我所知,layout_widthlayout_height在那里,那抱怨的是什么?

提前致谢!

1 个答案:

答案 0 :(得分:4)

你在xmlns中丢失了':':android =“http // ....”,试试

<Button xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:background="@drawable/key_bg"
    android:text="Q" />