Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoordinatorLayout not working in Android Studio 3.1.3?

I know this question has been asked a lot of times but I have tried most of the solutions, and none worked for me. This is the first time that I'm working on android studio 3.1.3, and I was following a tutorial on how to create a simple app using the basic template option from the android studio. The problem that I'm facing is; enter image description here

Render Problem Failed to find style 'coordinatorLayoutStyle' in current theme

I have tried adding this to the build.gradle file:

compile 'com.android.support:design:24.1.1'

Also this into the style.xml

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

styles.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" />

    Couldn't resolve resource @style/Widget.Design.CoordinatorLayout<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

build.gradle

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.notes"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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'
}
like image 236
Pedro Avatar asked Jun 20 '18 22:06

Pedro


People also ask

Is CoordinatorLayout deprecated?

The CoordinatorLayout. DefaultBehavior annotation is deprecated.

How do I use CoordinatorLayout?

By specifying Behaviors for child views of a CoordinatorLayout you can provide many different interactions within a single parent and those views can also interact with one another. View classes can specify a default behavior when used as a child of a CoordinatorLayout by implementing the AttachedBehavior interface.

Why is my design screen black in Android Studio?

Only preview and Design tab in Android Studio showing black screen. Please perform Invalidate/cache restart. try this :First you have to Sync your project. Next, go to Build menu, and clic on the Clean Project.

What is CoordinatorLayout Android studio?

Android CoordinatorLayout is a super-powered FrameLayout. It has a lot more to offer than it seems. It has additional level of control over it's child views. It coordinates the animations and transitions of child views with one another.


Video Answer


1 Answers

I was having the same problem. I tried following steps from here, but still the problem persists. I think it is a common issue in android studio 3.0+, Hopefully they will fix it next update. In the Android Studio Preview 3.2 it works fine. Download Android Studio Preview and visit here to learn how to run it alongside with Android Studio stable version

enter image description here

Or you can try to lower your design library version to 27. (And the compile sdk version also to 27)

dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' implementation 'com.android.support:design:27.0.2' }
like image 116
Nishan Avatar answered Sep 20 '22 04:09

Nishan