tablayout不会在recyclerview中膨胀

时间:2016-07-08 09:56:46

标签: android android-viewpager android-recyclerview android-tablayout android-inflate

我想在recyclerview项目中使用tablayout和viewpager,但是当android框架想要扩充我的布局时,我会收到此错误:

android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>

我的布局:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="500dp">

    <android.support.design.widget.TabLayout
        android:id="@+id/tablayout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:paddingBottom="4dp"
        android:paddingTop="4dp"
        android:textColor="@color/white"
        app:tabGravity="fill"
        app:tabMode="fixed"/>



    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/pager"/>


 </LinearLayout>

我使用compile&#39; com.android.support:design:23.4.0&#39;我的recyclerview在片段中,我的行为由AppCompatActivity扩展

我的傻瓜

apply plugin: 'com.android.application'
apply plugin: 'android-apt'




android {
   compileSdkVersion 23
   buildToolsVersion '24.0.0'
   useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "ir.gallery.main"
    minSdkVersion 14
    targetSdkVersion 22
    multiDexEnabled true
    versionCode 3906
    versionName "3.9.0.6"
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard-android.txt'
    }
    debug {
        minifyEnabled true
        proguardFiles 'proguard-android.txt'
    }
}


dependencies {
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:percent:23.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.liulishuo.filedownloader:library:0.3.2'
compile 'com.squareup:otto:1.3.8'
compile 'com.jakewharton:butterknife:8.1.0'
apt 'com.jakewharton:butterknife-compiler:8.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.android.support:multidex:1.0.0'
compile project(':utils')
}

1 个答案:

答案 0 :(得分:0)

在您的bulid.gradle中添加此依赖项

compile 'com.android.support:appcompat-v7:23.4.0'