Rendering problems in Android Studio v 1.1 / 1.2

2019-01-07 07:17发布

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?

11条回答
小情绪 Triste *
2楼-- · 2019-01-07 07:47

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 Layout Preview - Switch API to 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)

查看更多
相关推荐>>
3楼-- · 2019-01-07 07:47

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"

i.e., 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

查看更多
狗以群分
4楼-- · 2019-01-07 07:48

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

enter image description here

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'
}
查看更多
神经病院院长
5楼-- · 2019-01-07 07:54

Change android version from 22 to 21, problem solved, it's the little android icon at top right corner,

查看更多
三岁会撩人
6楼-- · 2019-01-07 07:55

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.

enter image description here

enter image description here

查看更多
登录 后发表回答