迁移到androidx后,Theme.AppCompat.Light.NoActionBar不起作用。

3

我曾在我的活动中使用Theme.AppCompat.Light.NoActionBar,这个主题可以完美地运行,但是我不得不迁移到 Androidx 来使用一个库,在迁移后现在出现了一个 actionBar。

我试着搜索了一些解决方案,但没有找到任何有效的方法。

以下是我的代码:

Style.xml

<style name="NoActionBar" 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>
</style>

Manifest.xml

<activity android:name=".LoginActivity" android:theme="@style/NoActionBar"
        android:configChanges="orientation" android:screenOrientation="portrait"/>

4
仍然存在这个问题:“未找到资源android:style/Theme.AppCompat.Light.NoActionBar”... :/ - Chet
2个回答

4

在迁移至AndroidX后,最好执行以下操作:文件菜单 > 清除缓存 / 重启


1
如果它不起作用,请尝试通过rm -rf /Users/user/.gradle/caches删除Gradle缓存。 - Douglas Mesquita

1

我解决了它。我只是清理并重新构建了项目。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接