Error inflating class android.support.design.widget.NavigationView

Android Studio3.3

主要错误在navigation_header这个布局里,layout_height ,开始这么写的:android:layout_height="?android:attr/actionBarSize"

改成:android:layout_height="?attr/colorPrimaryDark" 这个就好了

主要布局R.layout.activity_card_view:

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/dl_main_drawer"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".tabview.CardViewActivity"

    android:fitsSystemWindows="true">

   

        xmlns:app="http://schemas.android.com/apk/res-auto"

        style="@style/ActionBar"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical">

       

            android:id="@+id/appbar"

            style="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

            android:layout_width="match_parent"

            android:layout_height="wrap_content">

           

                android:id="@+id/toobar"

                style="@style/CustomTabTextAppearance"

                android:layout_width="match_parent"

                android:layout_height="?android:attr/actionBarSize"

                app:layout_scrollFlags="scroll|enterAlways">

               

                    android:id="@+id/tabs"

                    style="@style/MyCustomTabLayout"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    app:tabIndicatorColor="@color/colorAccent"

                    app:tabMode="scrollable">

               

           

       

       

            android:id="@+id/viewpager"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            app:layout_behavior="dddddddddd">

       

   

   

        android:id="@+id/nv_main_navigation"

        android:layout_width="wrap_content"

        android:layout_gravity="start"

        app:headerLayout="@layout/navigation_header"

        app:menu="@menu/drawer_view"

        android:layout_height="match_parent">

   

navigation_header :

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="?attr/colorPrimaryDark"

    android:orientation="horizontal"

    android:theme="@style/ThemeOverlay.AppCompat.Dark">

   

        android:layout_width="100dp"

        android:layout_height="100dp"

        android:layout_gravity="center_vertical"

        android:layout_marginLeft="50dp"

        android:scaleType="centerCrop"

        android:background="@drawable/ic_launcher_background" />

   

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center_vertical"

        android:layout_marginLeft="10dp"

        android:text="Liuwangshu"

        android:textAppearance="@style/TextAppearance.AppCompat.Body1"

        android:textSize="20sp" />

drawer_view:

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

   

       

            android:id="@+id/nav_home"

            android:icon="@mipmap/ic_launcher"

            android:title="首页"

            tools:ignore="DuplicateIds">

       

            android:id="@+id/nav_message"

            android:icon="@mipmap/ic_launcher"

            android:title="事项">

       

            android:id="@+id/nav_friends"

            android:icon="@mipmap/ic_launcher"

            android:title="音乐">

       

            android:id="@+id/nav_discussion"

            android:icon="@mipmap/ic_launcher"

            android:title="消息">

   

   

   

   

        android:icon="@mipmap/ic_launcher"

        android:title="设置" />

   

        android:icon="@mipmap/ic_launcher"

        android:title="关于我们" />

   

   



    app gradle 配置:

    apply plugin: 'com.android.application'

android {

    compileSdkVersion 28

    defaultConfig {

        javaCompileOptions {

            annotationProcessorOptions {

                includeCompileClasspath true

            }

        }

        applicationId "com.example.java.mypermissions"

        minSdkVersion 19

        targetSdkVersion 28

        versionCode 1

        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }

    }

    compileOptions {

        sourceCompatibility JavaVersion.VERSION_1_8

        targetCompatibility JavaVersion.VERSION_1_8

    }

}

ext{

    supportLibVersion = '27.1.1'

}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation "com.android.support:appcompat-v7:${supportLibVersion}"

    implementation "com.android.support:design:${supportLibVersion}"

    implementation "com.android.support:cardview-v7:${supportLibVersion}"

    implementation "com.android.support:recyclerview-v7:${supportLibVersion}"

  //  implementation 'com.android.support:appcompat-v7:27.1.1'

    implementation 'com.android.support:support-v4:27.1.1'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.github.hotchemi:permissionsdispatcher:2.1.3'

    annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.1.3'

    //Snackbar

  //  implementation 'com.android.support:design:27.1.1'

}


代码:git

你可能感兴趣的:(Error inflating class android.support.design.widget.NavigationView)