Put the toolbar, but I do not know how to programmatically change it. I wanted to try using getSupportActionBar (), but there was no such method by which it was possible to change the color

toolbar XML

<android.support.v7.widget.Toolbar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/toolbar" /> 

toolbar set in the onCreate method

 toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); } 
  • Do you want to change it dynamically in the program or just change it to the color you need? - ZigZag
  • In my opinion, it is best to create a separate topic, and at the start of the activation, choose the one you need with setTheme() - no news

1 answer 1

Programmatically, you can:

 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FF0000")));