gpt4 book ai didi

android - 在当前主题中找不到样式...

转载 作者:行者123 更新时间:2023-11-29 18:45:48 26 4
gpt4 key购买 nike

我在使用 android studio 时遇到了一个可疑的错误。每次我启动工作室并创建一个新项目时,都会出现另一个渲染错误

Failed to load AppCompat ActionBar with unknown error.

不是很明白是什么意思,但是通过replace很容易处理

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

到:

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

但是每当我向布局中添加新元素时,都会出现错误

Failed to find style ... in current theme Layout Theme = AppTheme

我找到了 solution ,这几乎帮助了除我以外的所有人。但是现在改变主题并不能解决问题。

如果有人知道如何处理它,请帮忙。

最佳答案

您可以复制样式名称 floatingactionbuttonstyle 并将其包含在您的应用主题中。

添加这一行

<item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>

最后主题是这样的

   <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>

</style>

Just add the style name when error occured in layout editor & add the responding styles.

这里为其他人添加了一些其他的样式。

   <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="chipStyle">@style/Base.Widget.MaterialComponents.Chip</item>
<item name="chipGroupStyle">@style/Widget.MaterialComponents.ChipGroup</item>
<item name="bottomNavigationStyle">@style/Widget.Design.BottomNavigationView</item>
<item name="coordinatorLayoutStyle">@style/Widget.Support.CoordinatorLayout</item>
<item name="bottomAppBarStyle">@style/Widget.MaterialComponents.BottomAppBar</item>
<item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>
</style>

您可以使用样式名称添加默认样式。然后解决这个错误。

关于android - 在当前主题中找不到样式...,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52012633/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com