简体   繁体   中英

Rendering problems in Android Studio v 1.1 / 1.2

When I add android.support.v7.widget.Toolbar or another android.support.v7.widget.* there are rendering problems.

But Support Library is up to date. And I complied in dependecies properly. I can import them in MainActivity.java

What is the problem?

UPDATE : Apparently they have fixed this bug in the final Android Studio 1.3 release (according to users reporting this issue solved in the issue tracker: https://issuetracker.google.com/issues/37043358 ).

This is a known bug since Android Studio build 1.1, which still exists in AS versions 1.2 and 1.3 beta. Switching the preview's API level from 22 to 21 fixes the for most people. While waiting for a fix you could try it as well.

Android Studio布局预览 - 将API切换为21

UPDATE: This is already reported as a known issue of Android Studio ( http://tools.android.com/knownissues#TOC-Can-t-Render-Layouts-in-Android-Studio-1.2 )

I don't know if this will help or not, but I was creating a test project (direct from the wizard, no custom code) and getting this error. Trying to modify the project structure and find the missing class didn't help.

The build failed with the following error:

***rendering problems

The following classes could not be found android.support.v7.internal.widget .ActionBarOverlayLayout***

Obviously it's not the final solution, but changing the Theme in design view from the base "project theme" to anything else allows it to build.

Possible solutions that worked for me:

1 -> Add the word Base. to the beginning of the theme name so that it reads "Base.Theme.AppCompat.Light.DarkActionBar"

ie, Change AppTheme parent in res/values/styles.xml to resolve this problem. Replace

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> 

with

 <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> 

OR

2- > Downgrade API level from 22 to 21 in preview pane as suggested by @david.schreiber

I changed the AppTheme above the graphical preview to Base.Theme.AppCompat and it disappeared for me. It worked on both 19 and 22 API :) ! Good Luck to all of you!

看看我做了什么
click for larger image

我将我的应用主题从“ Theme.AppCompat.Light.DarkActionBar ”更改为“ Base.Theme.AppCompat.Light.DarkActionBar

I encountered this problem just now in Android Studio 1.2.1.0 with API 22 (Android 5.1.1) selected without changing the theme or API as suggested by others on this thread.

When I updated to the most recent version of Android Studio available via the regular update check, it works fine now. This shouldn't be a problem in the new version Android Studio 1.2.1.1

将android版本从22改为21,问题解决了,它是右上角的小android图标,

Adding to david.schreiber's answer, if you keep your preview in a tight window you may wanna stretch it to access that Android icon.

在此输入图像描述

在此输入图像描述

I'm using Android Studio 1.2 as stable version and I have the same problem.

For me the solution was to use the Canary Channel and update Android Studio to 1.3.

Now I have this version and it works perfect but this is not and stable version

在此输入图像描述

My build.grade is this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "com.androidtest.materialdesign"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

将应用程序主题更改为Base.Theme.App.Compat为我工作。

  • Clean project
  • Rebuild project
  • Sync Gradle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM