Android studio 3.1 XML preview not showing for some XML layouts
Solution 1
For me, only "Force Refresh Layout" worked. Restarting, re-building, cleaning didn't work.
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.
Related videos on Youtube
P.C. Blazkowicz
Updated on June 04, 2022Comments
-
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.
-
AskNilesh about 6 years
-
-
P.C. Blazkowicz about 6 yearsYup, 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 about 6 yearsThat doesn't explain or fix the problems. This problem keeps reoccurring and you need to keep hitting the refresh
-
Rohan Taneja almost 6 yearsIt'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 almost 6 yearsWorked for me also, thanks! That's an hour of my life I'll never get back.
-
amedina almost 6 yearsMan, thanks so much, I would have never thought that the solution could be that.