Search code examples
androidandroid-studiocoordinator-layout

CoordinatorLayout does not display with targetSdkVersion 28 in AndroidStudio 3.1.4


I'm using the latest version of android studio (3.1.4), along with latest SDK version (28).

The layout does not get rendered in the design tab, I'm using coordinator layout.

styles.xml:

<resources>
    <style name="AppTheme" parent="Base.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>
</resources>

Layout code:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
tools:context=".FireBaseInterfaseActivity">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv_notas"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_plus"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="16dp"
    android:clickable="true"
    android:focusable="true"
    android:src="@drawable/ic_add" />
</android.support.design.widget.CoordinatorLayout>

Design TAB picture:

Design TAB image

How do I get around this problem?


Solution

  • Try changing your targetSdkVersion to 27 (File --> Project Structure --> app --> Flavors)

    and check your build.gradle(Module:app) file for this dependency:

    implementation 'com.android.support:appcompat-v7:27.1.1'
    

    if you already have this dependency and it still isn't working try adding this dependency:

    implementation 'com.android.support:design:27.1.1'
    

    I hope this helps you :)