Java Can';我无法解决表格布局问题

Java Can';我无法解决表格布局问题,java,android,layout,android-support-library,Java,Android,Layout,Android Support Library,无法解决表格布局问题。我几乎拥有作为解决方案提供的所有依赖项。项目已生成,但仍无法解决。我正在使用androidx,但我也尝试过使用28 依赖项: implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.android.volley:volley:1.1.1' testI

无法解决表格布局问题。我几乎拥有作为解决方案提供的所有依赖项。项目已生成,但仍无法解决。我正在使用androidx,但我也尝试过使用28

依赖项:

 implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.android.volley:volley:1.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.google.android.gms:play-services-ads:18.2.0'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation "androidx.fragment:fragment:1.1.0"
    //implementation 'com.android.support:support-v7:28.0.1'
    implementation 'com.android.support:support-v4:28.0.1'
    implementation 'com.android.support:design:28.0.1'
xml:

在该库中,
TabLayout
是。因此,将
android.support.design.widget.TabLayout
替换为
com.google.android.material.tabs.TabLayout

例如,我在AndroidStudio 3.5.1中使用空活动模板创建了一个废弃项目。我将
app/build.gradle
设置为:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29

    defaultConfig {
        applicationId "com.commonsware.myapplication"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
}

我可以从代码和布局中引用
com.google.android.material.tabs.TabLayout
,没有任何问题。

@JarrettWhite:查看更新的答案。你可以自己尝试一下,创建一个临时的Android Studio项目,在其中添加
implementation'com.google.Android.material:material:1.0.0'
,然后使用
TabLayout
(例如,通过Java/Kotlin代码中的构造函数创建一个实例)。我也尝试过,同样的问题。在这一点上,我几乎不知所措。我已经看完了所有关于TabLayout无法解决的问题的答案。我需要将任何内容导入java类吗?@JarrettWhite:“我需要将任何内容导入java类吗?”--您的问题中没有java类,因此我无法回答这个问题。是否需要导入才能引用TableLayout?它是在appcompat中,还是在另一个应用程序中import@JarrettWhite:导入将用于
com.google.android.material.tabs.TabLayout
com.google.android.material.tabs.TabLayout
是一个Java类的完全限定名。“我已将其更改为material”——然后提供一个显示修改后布局的示例。例如,您可能有打字错误。
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
implementation 'com.google.android.material:material:1.0.0'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29

    defaultConfig {
        applicationId "com.commonsware.myapplication"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
}