从Android Studio的“调色板”中拖放任何内容时,什么都没有出现

时间:2018-08-31 14:26:56

标签: android android-studio

概述

有一天,我启动了具有Android Studio功能的基本版面设计程序,但是一旦完成设置,“ Hello World!”我拖放的调色板中的文本和其他项目未显示在设计和蓝图中。我使这些项目可见,甚至更改了程序的设置和代码,但无济于事。

图片

I added a text and buttons from the palette, but the items didn't appear as shown in the image.

代码

以下是Gradle脚本中的一些代码:

注意:我在代码中更改了项目名称。

注意:我正在程序中使用功能。

“ build.gradle(项目:测试)”代码:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'


    // 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
}

“ build.gradle(模块:应用)”代码:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28



defaultConfig {
    applicationId "com.test.test.app"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"


}

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

}

dependencies {
implementation project(':Test_Feature')
implementation project(':base')
}

“ build.gradle(模块:基本)”代码:

apply plugin: 'com.android.feature'

android {
compileSdkVersion 28
baseFeature true
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
api 'com.android.support:appcompat-v7:28.0.0-rc02'
api 'com.android.support.constraint:constraint-layout:1.1.3'
application project(':app')
feature project(':Test_Feature')
}

“ build.gradle(模块:instantapp)”代码:

apply plugin: 'com.android.instantapp'

dependencies {
implementation project(':Test_Feature')
implementation project(':base')
} 

“ build.gradle(模块:Test_Feature)”代码:

apply plugin: 'com.android.feature'

android {
compileSdkVersion 28
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':base')
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'

}

“ settings.gradle(项目设置)”代码:

include ':Test_Feature', ':app', ':base', ':instantapp'

3 个答案:

答案 0 :(得分:0)

您可能应该做所有这一切:

Restart Android Studio
Rebuild Solution
Make sure you Target an insert point

答案 1 :(得分:0)

检查用于预览的AppTheme是否与在res-> values-> styles.xml中定义的相同。

有时主题不匹配时,在预览屏幕上显示内容会出现问题。

答案 2 :(得分:0)

当您从其他项目复制样式时,有时会发生这种情况。您可以清理并重建可在工具栏中的“构建”下找到的项目