Skip to content Skip to sidebar Skip to footer

Getting Message In Android App: Binary Xml File Line #2: You Must Supply A Layout_width Attribute

I'm trying to use a ListView inside of a RelativeLayout but when I run my app I get a runtimeexception with the message: Binary XML file line #2: You must supply a layout_width att

Solution 1:

The bug is here:

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

Look at the end of the line that starts with LinearLayout. You left a > which closes the tag, which means the attributes that follow are treated by the XML parser as a block of text, child of the LinearLayout tag. Just remove that extra > and you'll be fine.

Solution 2:

With respect to your comment, there's no Android widget for a label. You probably want a TextView instead.

Solution 3:

This is not an answer to your specific problem, but rather another cause of the same error.

I had a similar error, only my issue was that I entered schema, rather then schemas

ie.

LinearLayout xmlns:android="http://schema.android.com/apk/res/android"// wrong

LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"// correct.

Hope this helps others.

Post a Comment for "Getting Message In Android App: Binary Xml File Line #2: You Must Supply A Layout_width Attribute"