I'm trying to use NavigationView, but when I try to launch the app to the phone an error happens.
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.NavigationView
The xml files are:
activity_main:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<!--Contenido Principal-->
<include layout="@layout/main_content" />
<!--Menú Deslizante-->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/nav_menu"/>
</android.support.v4.widget.DrawerLayout>
Gradle File:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.shudy.XXXXXX"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.github.orhanobut:logger:1.12'
compile 'de.hdodenhof:circleimageview:1.3.0'
}
Error
06-16 14:00:16.883 10658-10658/com.shudy.XXXXX E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.shudy.XXXXX, PID: 10658
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shudy.XXXXX/com.shudy.XXXXX.MainActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I really don't know what is going, because is supposed taht is all OK.
EDIT, addded styles files
style
<resources>
<style name="Theme.EyeSky" parent="Base.AppTheme"/>
<!-- Base application theme. -->
<style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/window_background</item>
</style>
</resources>
style-v21
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.EyeSky" parent="Base.AppTheme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
EDIT 2
I'm using Android SDK Platform-Tools 23.1.0, and in gradle file:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:checked="true"
android:icon="@drawable/ic_home"
android:title="@string/home_item"/>
<item
android:id="@+id/nav_map"
android:checked="true"
android:icon="@drawable/ic_home"
android:title="@string/map_item"/>
<!-- Configuration section-->
<item
android:id="@+id/configuration_section"
android:title="@string/configuration_item">
<menu>
<item
android:id="@+id/nav_log_out"
android:icon="@android:drawable/ic_lock_power_off"
android:title="@string/log_out_item"/>
</menu>
</item>
</group>
</menu>
EDIT: Solution Found.
The problem was at navigation_header file. I had a ImageView, that for some reason, the height and width, didn't take it for the dimens.xml file. SO, I set it manually, and worked perfect. Here is how finally look,, this ImaveView (from a library)
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginBottom="16dp"
android:scaleType="centerCrop"
android:src="@drawable/perfil2"
app:border_color="@android:color/white"
app:border_width="1dp"/>