Android studio 3.1 XML preview not showing for some XML layouts

17,998

Solution 1

For me, only "Force Refresh Layout" worked. Restarting, re-building, cleaning didn't work.

enter image description here

Solution 2

i solved it by changing the below dependency

from

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

to

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

Solution 3

I've tried pretty much everything from above and nothing worked for me. Then I've downgraded my compileSdkVersion and targetSdkVersion

compileSdkVersion 27
targetSdkVersion 27

It worked! I've changed the versions back to 28 and it is still working.

Solution 4

You can change your dependency in build.gradle(module)

from

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

to

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

Solution 5

Layout Screen Not displaying ?

Just Open Styles.xml from --- Res -> Values -> Styles.xml

Replace:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

With:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

Your Display will come immediately. This is by just adding Base.

Share:
17,998

Related videos on Youtube

P.C. Blazkowicz
Author by

P.C. Blazkowicz

Updated on June 04, 2022

Comments

  • P.C. Blazkowicz
    P.C. Blazkowicz almost 2 years

    Some layouts are shown, some just have blank, gray frame. I can't seem to find a correlation between XML layouts that work and those that do not, there is a mixture of use of binding, constraint layout, varied in complexity and length, error-free. The app is compiling and running well.

    Any suggestions?

    Clearing cache/restarting, cleaning, rebuilding had no effect on this

    Solution: Noticed a red error icon next to layout in preview mode. It had something to do with id resources resolver @1 . I manually edited one of resource ids on a layout. This somehow fixed issue with rest of the layouts. Weird.

    Edit: It seems that problem keeps reoccurring. Changing theme on the preview does however help. I would also try to change preview mode to blueprint if you are having problems.

    Edit 2: I've went with Android Studio 3.2 Canary 9 and layouts are working as expected without problems. I'm guessing it had something to do with new-old bindings compiler

    Edit 3: Oh god... problems are not ending. 3.2 Canary 11 uses up all given memory fast while editing layouts and then GC keeps lagging all IDE for me. Need to restart IDE every 30mins. I end up reverting to 3.1.1 and if things are not loading I force refresh layout as it was suggested in below comment.

  • P.C. Blazkowicz
    P.C. Blazkowicz about 6 years
    Yup, I've just discovered this feature as well yesterday with 3.1.1 Works like a charm! Except it's not exactly a solution for why things are not loading in a first place
  • P.C. Blazkowicz
    P.C. Blazkowicz about 6 years
    That doesn't explain or fix the problems. This problem keeps reoccurring and you need to keep hitting the refresh
  • Rohan Taneja
    Rohan Taneja almost 6 years
    It's probably a bug on AndroidStudio. It'd be great if you could marks this as accepted since this does solve your problem :)
  • Jim In Texas
    Jim In Texas almost 6 years
    Worked for me also, thanks! That's an hour of my life I'll never get back.
  • amedina
    amedina almost 6 years
    Man, thanks so much, I would have never thought that the solution could be that.