如何在Android中将样式从NoActionBar更改为DarkActionBar

时间:2019-05-16 18:31:54

标签: android android-actionbar styles material-design android-drawable

嗨,如何将我的应用样式从DarkActionBar更改为NoActionBar? 我想要当用户单击按钮更改样式时 这是我的风格

<style name="AppThemeSearch" parent="Theme.MaterialComponents.Light.DarkActionBar">
    </style>
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    </style>

此代码不起作用

setTheme(R.style.AppThemeSearch);
MainActivity.this.recreate();

1 个答案:

答案 0 :(得分:0)

保持父样式不变:

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

</style>

并从您的activity

删除该代码