ToolBar color not changing in android -


i added standalone toolbar in activity, showing not showing color defined it. wrong code using?

below code using.

activity_categories.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     xmlns:ads="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center"     android:orientation="vertical"     android:weightsum="10"     android:background="#d32f2f"     tools:context="com.example.knowledgeup.loginactivity" >      <android.support.v7.widget.toolbar         android:id="@+id/toolbar"         android:layout_height="0dp"         android:layout_width="match_parent"         android:layout_weight="1"         android:elevation="4dp"         style="@style/toolbartheme" />      <linearlayout         android:layout_width="match_parent"         android:layout_height="0dp"         android:orientation="vertical"         android:layout_weight="8" >          <listview             android:id="@+id/list"             android:layout_width="match_parent"             android:layout_height="wrap_content" >         </listview>      </linearlayout>     </linearlayout> 

this how add activity in java file

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_categories);       mtoolbar = (toolbar)findviewbyid( r.id.toolbar );      mtoolbar.settitle(r.string.title_activity_categories);  } 

and styles.xml

<resources>      <!--         base application theme, dependent on api level. theme replaced         appbasetheme res/values-vxx/styles.xml on newer devices.     -->     <style name="appbasetheme" parent="theme.appcompat.light">         <!--             theme customizations available in newer api levels can go in             res/values-vxx/styles.xml, while customizations related             backward-compatibility can go here.         -->     </style>      <!-- application theme. -->     <style name="apptheme" parent="theme.appcompat.noactionbar">         <item name="android:windownotitle">true</item>         <item name="windowactionbar">false</item>     </style>      <style name="toolbartheme" parent="theme.appcompat">         <item name="colorprimary">@color/material_blue_grey_900</item>         <item name="colorprimarydark">@color/color_toolbar</item>     </style> </resources> 

this how showing enter image description here

try this

    <android.support.v7.widget.toolbar     android:id="@+id/toolbar"     android:layout_height="0dp"     android:layout_width="match_parent"     android:layout_weight="1"     android:elevation="4dp"     android:background = "@color/color_toolbar"     style="@style/toolbartheme" /> 

in activity_categories.xml

or in styles.xml

    <style name="toolbartheme" parent="theme.appcompat">     <item name="colorprimary">@color/material_blue_grey_900</item>     <item name="colorprimarydark">@color/color_toolbar</item>     <item name="android:background">@color/color_toolbar</item> </style> 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -