If your minSdk is 21 or higher, you can add the following:
<item name="colorPrimary">@color/yourColor</item>
If not, make the following changes:
Your activity should expand AppCompatActivity
Change the theme to @style/Theme.AppCompat.Light.NoActionBar
Add this to the top of your xml activity file:
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
Put this in your method onCreateafter the call super.onCreate:
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
To change color, simply replace ?attr/colorPrimarywith@color/yourColor
source
share