安卓预览中的空白屏幕 [英] Blank screen in android preview
问题描述
所以我的android studio有问题。我的预览只是一个没有内容的空白屏幕,我实际上已经添加了。当我在avd上运行它时,我可以看到这个按钮和文本视图,不幸的是预览屏幕仍然是空白的。我没有任何额外的库,我重新安装android工作室几次,只是创建了十个新项目 - 每个案例都结束相同。
So I have a problem with android studio. Mine "preview" is just a blank screen without content,that i actually added. When i run it on avd,i can see this button,and text view,unfortunetly the preview screen is still blank. I don't have any extra libraries,i reinstaled android studio couple of times and just created like ten new project - every case is ending same.
实际上看起来如何 - https://imgur.com/a/OX3JNLk
How it's look actually - https://imgur.com/a/OX3JNLk
推荐答案
更新build.gradle文件,以便compileSdkVersion和targetSdkVersion匹配您运行模拟器的版本。
Update the build.gradle file so the "compileSdkVersion" and "targetSdkVersion" matches the version you are running your emulator.
例如
compileSdkVersion 26
buildToolsVersion '26.0.2'
targetSdkVersion 26
compile "com.android.support:support-v4:26.0.2"
compile "com.android.support:design:26.0.2
还可以尝试这里提到的一些选项而不是预览,Android Studio只显示黑屏机智h'android ... ActionBarOverlayLayout'写在上面。
喜欢Goto:src - > main - > res - > style.xml并添加Base。样式标记父属性。
Also try some of the options mentioned here instead of preview, Android Studio showing only black screen with 'android...ActionBarOverlayLayout' written on it. Like Goto: src -> main -> res -> style.xml and add Base. to the style tag parent attribute.
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
...
</style>
这篇关于安卓预览中的空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!