0

I am new to Android Studio and I was trying to figure out the Design Editor. I was following this guide, and I enabled "show constraints", but in my design editor the constraints don't show up. Also, the "Hello World" doesn't show. My question is: How come the constraints are invisible, and what is the reason that I can't add components to the constraint layout?

The XML file I use is the default from the 'Basic Activity' template included in Android studio:

<?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 did notice that within the blueprint in the top left corner of my blueprint, there is a very small square, which turns out to be the TextView within the constraintlayout when I click on it. Furthermore, within the component tree, in noticed that the main (and only) constraintlayout is marked with the following error: The recourse @string/appbar_scrolling_view_behaviour is marked as private in com.android.support:design. I'm not sure whether this has anything to do with my problem, as it seems to be a problem within the dependency from Google.

Speaking of dependencies; here are the dependencies in the build.gradle(Module:app) that I use:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:28.0.0-alpha3'
    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'
}

I have been trying to figure this out for the past few days and I can't find post with the same problem. If anyone could help me out it would be greatly appreciated. I will post it here if I somehow manage to fix it or find a solution elsewhere.

jurrdb
  • 301
  • 3
  • 13

2 Answers2

0

Okay, so I found this post, where the same problem is described where an older support dependency is used. That problem was fixed by downgrading support dependencies from 26.0.0-beta2 to 26.0.0-beta1. I was using 28.0.0-alpha3 so I figured this wouldn't help me. It appears, however, that downgrading to 28.0.0-alpha1 solves this problem.

Leaving this here for those who encounter the same problem.

jurrdb
  • 301
  • 3
  • 13
0

Try with stable libraries:

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.1.1'
Jorge Najera
  • 75
  • 1
  • 11
  • I couldn't downgrade to 27.x versions since I'm using API 28. Downgrading to 28.0.0-alpha1 did help however, so I guess you're right that that is the problem! Thank you – jurrdb Jun 30 '18 at 19:00