Friday, 15 August 2014

android - Change Toolbar color in Appcompat 21 -



android - Change Toolbar color in Appcompat 21 -

i testing out new appcompat 21 material design features. hence i've created toolbar this:

<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_my_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary" app:theme="@style/themeoverlay.appcompat.actionbar"/>

and included in main layout file.

then i've set supportactionbar that:

toolbar toolbar = (toolbar)findviewbyid(r.id.activity_my_toolbar); setsupportactionbar(toolbar);

it's working, somehow can't quite figure out how customize toolbar. it's gray , text on black. how should alter background , text color?

i've gone through instructions:

http://android-developers.blogspot.de/2014/10/appcompat-v21-material-design-for-pre.html

what have overseen alter colors?

<style name="apptheme" parent="theme.appcompat.light"> <item name="android:windowactionbar" tools:ignore="newapi">false</item> <item name="windowactionbar">false</item> </style>

edit:

i able alter background color adding these lines of code theme:

<item name="colorprimary">@color/actionbar</item> <item name="colorprimarydark">@color/actionbar_dark</item>

but won't impact text color. missing? instead of black text , black menu button, i'd rather prefer white text , white menu buttons:

again in link supplied

to alter text white have alter theme.

use theme

<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_my_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary" app:theme="@style/themeoverlay.appcompat.dark.actionbar" app:popuptheme="@style/themeoverlay.appcompat.light"/>

android android-actionbar appcompat android-actionbar-compat android-toolbar

No comments:

Post a Comment