12

My code is:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:theme="@style/Toolbar_Theme"/>

I want to change app:theme in java code. Can i find any method as toolbar.setTheme which used to change style of toolbar?

mixel
  • 25,177
  • 13
  • 126
  • 165
Ahmed Mohammed
  • 337
  • 3
  • 16
  • 2
    You can only change the background color and the title color using code : toolbar.setBackgroundColor(newColor); toolbar.setTitleTextColor(titleColor); – mariuss Oct 04 '15 at 09:05
  • 1
    Try this : https://stackoverflow.com/questions/31225189/how-to-change-appcompat-v21-toolbar-theme-programmatically – Abdeldjalil Elaaeieida Jan 02 '18 at 18:36

1 Answers1

-10

You can change it programmatically like this:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

toolbar.getContext().setTheme(R.style.ThemeOverlay_AppCompat_Dark_ActionBar);
Pedro
  • 22
  • 2