Agustín Clemente
Agustín Clemente

Reputation: 1268

Android Studio's Project Preview is Blank in a New Project

I just started learning some Android Studio, but when I create a project, the "Hello World" template isn't showing on the preview window, even if I make changes or add elements to the xml layout. On my phone it shows perfectly, but I can't make it work on the IDE.

Here's my screen

Upvotes: 3

Views: 1053

Answers (1)

Ali Bdeir
Ali Bdeir

Reputation: 4365

This is a known bug. Here are the many options to fix it:

  • Build > Clean Project
  • Build > Rebuild project
  • File > Invalidate Caches/Restart
  • If all else fails, go to your styles.xml located in res/values. Make sure you're using the parent="Theme.AppCompat.Light.NoActionBar" theme, instead of the default. (If you want a dark theme, do the obvious and change it to Theme.AppCompat.Dark.NoActionBar

Why this happens/Why this fixes it:

For some reason, Android Studio still uses the deprecated ActionBar by default and I don't think the layout editor supports it anymore. Thus it's crashing anonymously.

To use a Toolbar since the ActionBar is deprecated, follow this link:

https://developer.android.com/training/appbar/setting-up

(^ You can probably skip Step 1 in the above link)

Upvotes: 3

Related Questions