Android Studio-ActionBar未显示在预览中

时间:2018-06-28 19:02:57

标签: android android-actionbar

在设备上运行应用程序时,可以看到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也出现在预览中? 谢谢。

2 个答案:

答案 0 :(得分:1)

我假设您正在使用某种appcompat-v7:28.0.0-*版本。我刚刚遇到了同样的问题。对我来说,解决方案是更改build.gradle文件(模块: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的“设计视图”部分存在错误。

答案 1 :(得分:1)

我处理了同样的问题,我想找到了解决方法

  1. 首先打开布局编辑器窗口,然后单击左上角的眼睛,如下所示,然后单击“显示布局装饰”

enter image description here

  1. 您也可以在此处更改应用,因此您的工具栏,操作栏等...

enter image description here

相关问题