0

in my android studio 3.1.3 while it will show the following errors

Failed to find style 'coordinatorLayoutStyle' in current theme

Button

**This view is not constrained. It only has design-time positions, so it will jump to (0,0) at runtime unless you add the constraints.**

and design window always shows blank

and it will take a lot of time to load

any suggestions...?

here is the image

content_main.xml

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

Style.xml

<resources>

<!-- Base application theme. -->
<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>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
Darshan
  • 1
  • 7

3 Answers3

1

Problem with coordinator layout and blank design window: This usually happens when you try to compile your project with the Android API level 28. Go to your Gradle file (module) and change everywhere API level 28 by 27. Also, in the downside of the file, there's probably by default some entries with API version 28.x.xbeta. Change it by version 27.1.1. Sync and build project and you should be ok.

Some views are not constrained: That happens because you are using ConstraintLayout and therefore the views must be constrainted to other elements to keep their position on screen. This is easy as you simply can drag the circles on the edges (in design view), and drop the arrow to the other views on the screen. You can see more info at: https://developer.android.com/training/constraint-layout/ I suggest you to learn how to use it as it is a nice and useful layout.

  • I tried that but show some error ...Failed to resolve: com.android.support:appcompat-v7:27.0.0-beta01 Failed to resolve: com.android.support:design:27.0.0-beta01 – Darshan Aug 11 '18 at 06:32
  • Change that "27.0.0-beta01" by 27.1.1. Android Studio perhaps shows an error saying the you haven't that build version installed, but it gives an option to install it. – Miguel Ortiz Aug 11 '18 at 06:40
0

I have solved this rendering problem in Android Studion 3.1.3 by just adding this lines in application theme.

<style name="AppTheme.NoActionBar">
  <item name="coordinatorLayoutStyle">@style/Widget.Design.CoordinatorLayout</item>
</style>

Actually it is android sdk 28 issue.

Hope this will help you...Let me know if not we might find other solution also.

Lokesh Desai
  • 2,607
  • 16
  • 28
0

Please insert below line code in your build.gradle file after implementation 'com.android.support:appcompat-v7:27.1.1'

// here you can use your latest version which you have use in `com.android.support:appcompat-v7` instead of `27.1.1` 

implementation 'com.android.support:design:27.1.1'
Nirav Bhavsar
  • 2,133
  • 2
  • 20
  • 24