【问题标题】:Delete the night mode in my android application | android studio在我的 android 应用程序中删除夜间模式 |安卓工作室
【发布时间】:2020-12-15 07:38:45
【问题描述】:
我不想在我的应用程序中使用夜间模式,我试图删除一个文件 themes.xml (night),但这没有用,我还尝试将 themes.xml 文件内容移动到 themes.xml (night) 并且它没有也不行。
themes.xml file
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
你能帮我吗?谢谢!
【问题讨论】:
标签:
android-studio
android-layout
android-theme
【解决方案1】:
请在样式文件中使用默认应用主题,而不是“Theme.AppCompat.DayNight.NoActionBar”。
除非我们在风格上使用 Day Night 主题,否则夜间模式将不起作用。在那里,您可以使用应用程序的默认主题来禁用暗模式。
<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>
</style>
【解决方案2】:
尝试添加这个
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">
然后这个在布局中
android:forceDarkAllowed="false"