Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.design.widget.NavigationView

I am new to android app development and I have the following error:

Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.design.widget.NavigationView

I have an activity - WorkingActivity.cs, which looks like this:

[Activity(Label = "WorkingActivity", Theme = "@style/AppTheme")]
public class WorkingActivity : AppCompatActivity
{
    DrawerLayout drawerLayout;
    NavigationView navigationView;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        //getting error here
        SetContentView(Resource.Layout.activity_working);

    }

}

Corresponding layout file - activity_working.axml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
  android:orientation="vertical"    
  android:layout_width="match_parent"    
  android:layout_height="match_parent">    
  <android.support.v4.widget.DrawerLayout 
     xmlns:app="http://schemas.android.com/apk/res-auto"    
     android:id="@+id/drawer_layout"    
     android:layout_height="match_parent"    
     android:layout_width="fill_parent"    
     android:fitsSystemWindows="true">    
  <LinearLayout    
     android:layout_width="match_parent"    
     android:layout_height="match_parent"    
     android:orientation="vertical">    
  <include layout="@layout/toolbar" />    
  </LinearLayout>    
  <android.support.design.widget.NavigationView    
     android:id="@+id/nav_view"    
     android:layout_height="match_parent"    
     android:layout_width="300dp"    
     android:layout_gravity="start"   
     android:fitsSystemWindows="true"    
     app:headerLayout="@layout/nav_header" />    
  </android.support.v4.widget.DrawerLayout>   
</LinearLayout>

nav_header.axml file:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
  xmlns:app="http://schemas.android.com/apk/res-auto"    
  android:layout_width="match_parent"    
  android:layout_height="100dp"    
  android:background="#0099ff"    
  android:padding="16dp"    
  android:orientation="vertical"    
  android:gravity="bottom">    
<TextView    
  android:text="User Name"    
  android:layout_width="match_parent"    
  android:layout_height="wrap_content"    
  android:id="@+id/navheader_username"    
  android:textAppearance="@style/TextAppearance.AppCompat.Body1" />    
</LinearLayout>  

toolbar.axml file:

<?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"    
  xmlns:app="http://schemas.android.com/apk/res-auto"    
  android:id="@+id/main_content"    
  android:layout_width="match_parent"    
  android:layout_height="match_parent">    
  <android.support.design.widget.AppBarLayout    
     android:id="@+id/appbar"    
     android:layout_width="match_parent"    
     android:layout_height="wrap_content"    
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">    
  <android.support.v7.widget.Toolbar    
     android:id="@+id/toolbar"    
     android:layout_width="match_parent"    
     android:layout_height="wrap_content"    
     android:elevation="4dp"    
     android:background="?attr/colorPrimary" />    
  </android.support.design.widget.AppBarLayout>    
</android.support.design.widget.CoordinatorLayout>

styles.xml:

<resources>


<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  <item name="android:textColorPrimary">#212121</item>
  <item name="android:textColorSecondary">#727272</item>
  <item name="windowActionBar">false</item>
  <item name="windowNoTitle">true</item>
</style>

</resources>

these are references of my project:

enter image description here

This error appears when I add (only add, nothing else) a new layout file, called activity_new_visit.axml (name doesn't matter) in the same folder:

activity_new_visit.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</LinearLayout>    

What is the reason?

EDIT:

I uploaded project on github: https://github.com/AlexDev5/App2

like image 965
Alexander Mujirishvili Avatar asked Apr 22 '26 18:04

Alexander Mujirishvili


1 Answers

I found solution on forums.xamarin.com:

enter image description here

like image 196
Alexander Mujirishvili Avatar answered Apr 26 '26 07:04

Alexander Mujirishvili



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!