无法在当前主题中找到样式... [英] Failed to find style ... in current theme

查看:90
本文介绍了无法在当前主题中找到样式...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用android studio的过程中,我遇到了一个可疑的错误. 每次我启动Studio并创建一个新项目时,都会出现另一个渲染错误

I've faced a questionable error during my work with android studio. Everytime I start studio and create a new project there is another render error

无法加载具有未知错误的AppCompat ActionBar.

Failed to load AppCompat ActionBar with unknown error.

我不清楚这是什么意思,但是通过替换很容易解决

I do not clearly understand what does it mean, but it is easy to deal with it via replacing

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

收件人:

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

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

but evertime I add new element to the layout, there is error

无法在当前主题中找到样式...

Failed to find style ... in current theme

我找到了解决方案,该解决方案几乎可以除我以外的所有人.但是现在更改主题并不能解决问题.

I have found a solution, that helped almost everybody except me. But changing theme now doesn't solve the problem.

如果有人知道如何处理,请提供帮助.

If anybody know how to deal with it please help.

推荐答案

您可以复制样式名称floatingactionbuttonstyle并将其包含在您的应用程序中.

You can copy the style name floatingactionbuttonstyle and included it in your apptheme.

添加此行

<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>

只要在布局编辑器&发生错误时添加样式名称即可.添加响应样式.

在其他样式中添加了其他一些元素.

Here some other few elements am added in styles for others.

   <!-- 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>

您可以使用样式名称添加默认样式.然后,您可以解决此错误.

You can add default style with style name. Then you resolve this error.

这篇关于无法在当前主题中找到样式...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆