I have a custom toolbar for my app, but in one of the activities I want to change the style of the toolbar programatically. This is the style for the toolbar that I want to apply programmatically.
<style name="toolbarStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:background">@color/teal_200</item>
<item name="colorAccent">@android:color/white</item>
</style>
I use this code to change toolbar style programmatically
toolbar.getContext().setTheme(R.style.toolbarStyle);
The problem is, the popup theme changes instead of the toolbar.
How to fix it?