Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Why do I get this error? Android.Views.InflateException:

Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: You must supply a layout_width attribute.
Text of the AXML is attached.
I have read extensively online. What I see is either the Layout width IS missing, or this is being used as a catchall error of some kind. I don't see any missing layout_width statements so I am guessing it is some other obscure syntax error.
Help I have been stuck on this one for quite a while.

Best Answers

Answers

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    Your table rows don't have a width set.

  • DavidSheesleyDavidSheesley USMember

    I have added TableRow Layout_Width's and get the same result. The new AXML is attached.

  • SreeeeSreeee INMember ✭✭✭✭✭

    @JimBennett Having the same issue, all layout have layout_height and layout_width: Please help me to find the issue.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFCDD2"
        android:orientation="vertical">
        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <EditText
                android:id="@+id/input_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:hint="@string/hint_name" />
        </android.support.design.widget.TextInputLayout>
        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <EditText
                android:id="@+id/input_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress"
                android:hint="@string/hint_email" />
        </android.support.design.widget.TextInputLayout>
        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <EditText
                android:id="@+id/input_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:hint="@string/hint_password" />
        </android.support.design.widget.TextInputLayout>
        <Button
            android:id="@+id/btn_signup"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/btn_sign_up"
            android:background="@color/colorPrimary"
            android:layout_marginTop="40dp"
            android:textColor="@android:color/white" />
    </LinearLayout>
    
  • SreeeeSreeee INMember ✭✭✭✭✭

    Update: Issue is with theme :)

    Forget to add Theme.AppCompat theme for my activity, solved it by following steps:

    Create a styles.xml file under Resources\values\ folder with below codes:

    <?xml version="1.0" encoding="utf-8" ?> 
    <resources>
     <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        </style>
    </resources>
    

    In MainActivity.cs define the Activity attribute to leverage AppTheme like this:

    [Activity(Label = "DinexFeedback", MainLauncher = true, Icon = "@drawable/icon",Theme ="@style/AppTheme")]
    public class MainActivity : Android.Support.V7.App.AppCompatActivity
    {
       ...
    }
    
Sign In or Register to comment.