Search code examples
androidandroid-layoutandroid-studioandroid-studio-3.1.3

Android studio is not showing toolbar but device is showing it


I'm using

Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-29-generic

with dependencies

implementation 'com.android.support:appcompat-v7:28.0.0-beta01'

Here is Toolbar Layout:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:theme="@style/ToolBarStyle" />

Problem: Android studio is not showing design layout but I can see Toolbar when I run the code.


Solution

  • This is a bug in sdk 28. They will fix this in one of the future updates. Probably when its stable version is out. I've also encountered this problem, and what I do is that:

    1) Test on emulator or a real device.

    OR

    2) Code my project in sdk 27(this way I can see the layouts), and while testing on a device, I change it to sdk 28.

    I hope this answer helps you.