错误无法解析符号TabLayout和'设计

问题描述 投票:7回答:2

请帮助:导入时我得到错误android.support.design.widget.TabLayout它说"can not resolve symbol 'design'

我的build.gradle:

     compileSdkVersion 26
     buildToolsVersion "26.0.0"

     dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
         androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
         {
             exclude group: 'com.android.support', module: 'support-annotations'
         })
         compile 'com.android.support:appcompat-v7:26'
         compile 'com.android.support.constraint:constraint-layout:1.0.2'
         compile 'com.android.support:support-v4:26'
         testCompile 'junit:junit:4.12'
     }
android android-studio android-gradle android-tablayout android-design-library
2个回答
21
投票

你忘了添加设计支持库。只需在gradle app文件中添加此依赖项:

implementation 'com.android.support:design:26.0.+'

Design Support Library

Design包提供API以支持向您的应用添加材料设计组件和模式。

设计支持库增加了对应用程序开发人员构建的各种材料设计组件和模式的支持,例如navigation drawersfloating action buttons (FAB)snackbarsTabLayout

或者AndroidX依赖:

implementation "com.google.android.material:material:1.0.0"

3
投票

如果您想使用doc,您可以检查TabLayout,您必须添加此依赖项:

com.android.support:design:26.0.2

build.gradle区块添加你的dependencies

compile 'com.android.support:design:26.0.2'
© www.soinside.com 2019 - 2024. All rights reserved.