I can not see anything on the design screen. (Android Studio)

1

I just started with Android Studio and it gives me nothing but problems. In principle when I create a basic activity project, everything seems to be going well. but when I enter the graphic part of the design screen I see this and I do not see anything.

And here I put the piece of code of my content_main

<?xml version="1.0" encoding="utf-8"?>
  <android.support.constraint.ConstraintLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context=".MainActivity"
  tools:showIn="@layout/activity_main">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

I've been trying to find solutions in Google for weeks and I can not find anything. Please, someone who can solve it for me?

    
asked by Eduardo Ruiz Moreno 13.06.2018 в 16:30
source

4 answers

1

The line that causes the view to not be able to be built and at the same time can not be seen in the Design option is tools: showIn as it does not find the > Layout assigned, so you should check the route where content_main and activity_main if you share the route the line would look like this:

tools:showIn="activity_main"

Greetings.

    
answered by 13.06.2018 / 17:47
source
1

I solved it like this:

En res/values/style.xml

just modify that part the rest of the code should remain the same as the one that was generated.

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="coordinatorLayoutStyle">Widget.Design.CoordinatorLayout</item>
</style>
    
answered by 20.06.2018 в 03:50
0

This seems to be a bug in the Android Studio template. The truth is that until I've tried it, I was not sure what the problem was.

If you look at your own screenshot, it tells you there is an error. If you deploy it, the error is probably this:

  

Failed to load AppCompat ActionBar with unknown error in android studio

After an extensive search, it seems that this error is solved in the following way:

  • Go to the file /res/values/styles.xml

  • In that style file, you must add Base before the topic. It is dedir, modify:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    </style>
    

    for

    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    </style>
    

Recharge the view and you should see the components in the designer.

Reference: link

    
answered by 13.06.2018 в 17:25
0

The design view sometimes can not be rendered (rendering), this happens when you find an error in the layout, personally I think it can also be due to memory and IDE error.

Some Android Studio versions even have problems with the ConstraintLayout , in fact it shows you a warning.

You can restart your IDE and sometimes this is resolved.

But I suggest you upgrade to Android Studio 3.1.2 version now I have no problem with this.

Even the design view of the layout is shown even though there are problems in visualizing it.

Update:

This is the minimum configuration that can solve the problem:

use:

dependencies {
    ...
    implementation 'com.android.support:appcompat-v7:26.1.0'
    ...
}

with:

 compileSdkVersion 26
 buildToolsVersion "26.0.1"

and within the file build.gradle located in the root of the project, use minimum gradle version 3.0.1:

buildscript {
    ...
    ....
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        ...
        ...
    }
}
    
answered by 13.06.2018 в 17:26