【问题标题】:Layout is not seen in the design section of the android studio,but it works on deviceandroid studio的设计部分没有看到布局,但它适用于设备
【发布时间】:2019-07-13 20:11:36
【问题描述】:

我已经尝试了很多解决并按照此链接进行操作 StackOverflow 但没有任何反应。我介绍自己是 android 编程和学习自己的初学者。

//values文件夹中styles.xml的代码

<?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
            <item name="android:layout_width">fill_parent</item>
            <item name="android:layout_height">wrap_content</item>
            <!--<item name="android:textColor">#00FF00</item>-->
            <!--<item name="android:typeface">monospace</item>-->
        </style>
    </resources>

//and code for build.gradle Module:app is

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.madhav.schoolmanagement"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    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'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:appcompat-v7:+'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

repositories {
    google()
}

buildscript {
    repositories {
        google()
    }
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

【问题讨论】:

  • 在您的屏幕截图中,有一个带有感叹号的红色圆圈(缩放按钮旁边)。单击该按钮,您将了解为什么不显示预览。
  • 尝试粘贴我的答案中的相同资源并重建您的项目
  • @VipulChauhan 我按照你说的做了,但是没有用
  • 终于通过这个链接解决了[stackoverflow.com/questions/42477738/….非常感谢您的帮助。@VipulChauhan,@sohel yadav,@Nurlan

标签: android xml


【解决方案1】:

是的,如果它对你有帮助,一些用户会尝试这个

1 转到应用

2 源代码

3 主要

4 分辨率

5 个值 // 打开这个..

然后将其更新为

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

【讨论】:

  • 因为当我开始与工作室合作时,我也陷入了这个问题
  • 好吧,对不起,我认为这是另一个错误,正如您在上面所说的,您已经尝试过清理项目并使其无效并重新启动。我不知道另一种解决方案,但我有一个解决方案可以在另一个项目中尝试相同的布局,这实际上是布局问题或 android studio 问题
【解决方案2】:

我认为您尚未更新您的 Android Studio。 解决方案是 Base.Theme.AppCompat.Light.NoActionBar

【讨论】:

    【解决方案3】:

    默认的styles.xml 应该是这样的

    <resources>
    
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
    
    </resources>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-25
      相关资源
      最近更新 更多