在设备上运行应用程序时,ActionBar可见,但它不在预览部分中。
在预览中:https://i.stack.imgur.com/dNjAz.png
在设备上:https://i.stack.imgur.com/IjIHn.png
这是styles.xml
<!-- Base application theme. -->
<style name="Theme.AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
如何让ActionBar也出现在预览中?谢谢。
我假设你正在使用某种appcompat-v7:28.0.0-*
版本。我刚遇到同样的问题。我的解决方案是更改build.gradle文件(Module:app)中的实现行。
替换它
implementation 'com.android.support:appcompat-v7:28.0.0-rc01' (or anything like this)
这样
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
根据this的帖子,一些appcompat-v7:28.0.0-*
版本有一个Android Studio的“设计视图”部分的错误。