【问题标题】:Android Studio GridLayout not working. Shows completely grey into Design ViewAndroid Studio GridLayout 不工作。在设计视图中显示完全灰色
【发布时间】:2020-07-29 14:58:21
【问题描述】:

我希望有人可以帮助我:S

我正在使用 Android Studio 3.6.2,Gradle 版本是 5.6.4。

我只是尝试将 GridLayout 拖放到 ConstraintLayout 中。但由于某种原因,GridLayout 完全显示为灰色。

我在研究中读到可能与 Gradle 文件有关的内容。我读到我需要:

1)implementation 'androidx.gridlayout:gridlayout:1.0.0'

2)

repositories {
        google()
    }

我的 Gradle 文件中包含这两个文件。那么,我是否在某处遗漏了什么?

我上传了一张参考图片和一些代码。在此先感谢 ;)

Design View

build.gradle(项目:AndroidSample)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.aretius.androidsample"
        minSdkVersion 26
        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 fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
}

build.gradle(模块:app)

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

  • 您可以直接将屏幕截图粘贴到 Stackoverflow 上。内嵌图片有助于阅读问题。
  • 我想要,但它说“你还不能在你的帖子中嵌入图片,所以我们已经包含了一个链接。”

标签: android-studio android-gradle-plugin android-gridlayout


【解决方案1】:

好吧,我终于解决了用最新版本重新安装 Android Studio 的问题 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-22
    • 2016-06-10
    • 2015-11-25
    相关资源
    最近更新 更多