【问题标题】:Android Studio 1.5.1 rendering problemsAndroid Studio 1.5.1 渲染问题
【发布时间】:2016-01-13 17:10:51
【问题描述】:

我是 android studio 新手,我安装了一个新版本(版本 1.5.1)。 出于某种原因,我不断收到一条错误消息(每次我使用应用程序主题时),说存在渲染问题:缺少样式。 我在网上寻找解决方案,但大多数都已过时或根本不起作用。

感谢您的帮助。

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.easycodingplus.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

构建等级:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.easycodingplus.myapplication"
        minSdkVersion 8
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

【问题讨论】:

标签: android android-studio android-theme


【解决方案1】:

只需像这样更改您的 style.xml 文件

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

然后,转到

文件 > 项目结构 > 应用程序 >

并设置(都应与最新版本相同)

source compatibility : 1.7

Target compatibility : 1.7

【讨论】:

  • 我刚刚将TargetSource 兼容性从空白更改为1.7,然后屏幕加载正常。谢谢
【解决方案2】:

您必须包含dependencies 进行设计,就像这样,这将添加到build.gradleapp 模块的dependencies 块下

compile 'com.android.support:design:23.1.1'

应该是这样的..

你需要这个支持库作为 CoordinatorLayoutAppBarLayoutFloatingActionButton 的一部分

在样式文件中创建样式

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

并在您的 AndroidManifest 文件中引用它

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">// like this

【讨论】:

  • 我已经有这样一行代码:compile 'com.android.support:design:23.1.1'
  • @Yaron,您是否将 Project 与 gradle 文件同步?
  • 我遇到了这种问题,所以我将样式从这个
  • 我做到了,但它没有帮助,正如我在网上查看并尝试了尽可能多的解决方案之前所说的那样,但没有一个有效。
  • @Yaron,您的主题有问题,请尝试使用 AppCompat
【解决方案3】:

请确保您在 build.gradle 文件中将最新的 AppCompat 库列为依赖项:

com.android.support:appcompat-v7:23.1.0

您能发布错误所指的样式吗?您可能需要在 res > values > styles 文件夹中添加样式。您的代码中的某些内容可能引用了该文件夹中不存在的样式。

【讨论】:

  • 谢谢,但这没有帮助。我有“编译'com.android.support:appcompat-v7:23.1.1'”但它仍然不起作用。
【解决方案4】:

试试这个方法:

保持您的互联网连接

在 android studio 工具栏中转到“文件”,点击“invalidate caches/Restart”并选择“invalidate and restart”

【讨论】:

  • 我没有这个选项。
【解决方案5】:

3 个选项

1.选择低级API版本

2.Add Base on styles.xml

3.安装以前的 SDK(如果需要)

【讨论】:

    【解决方案6】:

    我也遇到了同样的问题,所以我做了什么...转到sdk manager -->勾选android 5.1.1 api level 22并安装它...。 然后转到预览窗口并选择其他版本

    【讨论】:

      【解决方案7】:

      我遇到了同样的问题,这些步骤帮助我解决了这个问题: 1. 文件 > 其他设置 > 默认设置 > 外观和行为 > 文件编码。 2.将项目编码改为windows-1252。然后: 3. 文件 > 使 Chaches 无效/重新启动。 或最坏的情况 将主题更改为 Material light 或其他东西,其中一个应该可以工作。 我希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-21
        • 2014-10-13
        • 2015-09-14
        相关资源
        最近更新 更多