0

I am trying to change color of home arrow indicator in custom toolbar. There is list of examples that I found but nothing worked for me.

Here is my layout

<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/title_bar_toolbar_id"
    app:theme="@style/ToolbarColoredBackArrow"
    app:popupTheme="@style/AppTheme"
    android:layout_height="?attr/actionBarSize"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:minHeight="?attr/actionBarSize"
    android:colorControlNormal="@color/hamburger_color"
    android:background="@color/custom_theme_color" >

    <LinearLayout
        android:id="@+id/base_title_bar_toolbar_id_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/activity_calendar_toolbar_change_view_type"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/select_semester_view"
            android:layout_gravity="center_vertical"
            android:padding="10dp" />

        <TextView
            android:gravity="center"
            android:layout_gravity="center"
            android:id="@+id/base_title_bar_toolbar_header"
            android:layout_weight="0.1"
            style="@style/CustomToolBarTitleStyleBase"
            android:text="@string/calendar" />

        <ImageView
            android:padding="13dp"
            android:id="@+id/activity_calendar_toolbar_save_date_to_calendar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/save_date_to_calendar"
            android:layout_gravity="center_vertical|start" />

        <ImageView
            android:id="@+id/activity_calendar_toolbar_select_semester_to_show"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/select_semester_to_show"
            android:layout_gravity="center_vertical|start"
            android:padding="13dp" />

    </LinearLayout>
</android.support.v7.widget.Toolbar>

The styles are:

<style name="ToolbarColoredBackArrow" parent="AppTheme">
    <item name="android:textColorSecondary">@color/hamburger_color</item>
    <item name="android:textColorPrimary">@color/hamburger_color</item>
    <item name="colorControlNormal">@color/hamburger_color</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/custom_theme_color</item>
    <item name="android:titleTextStyle">@style/MyActionBar.TitleTextStyle</item>

    <!-- Support library com`enter code here`patibility -->
    <item name="background">@color/custom_theme_color</item>
    <item name="titleTextStyle">@style/MyActionBar.TitleTextStyle</item>
</style>

I tried all possibilities that I found in examples, but nothing worked for me.

V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
Michael
  • 1
  • 1

2 Answers2

1

Haha, this is one of the most frustrating styling issues in Android right now...

Try creating a style like this

<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:textColorSecondary">#000000</item> 
</style>

and using it in your Activity (you will probably want to merge it with your current style, as it is just the parent and this one param that matters) and of course replace the #000000 with some other color.

Kelevandos
  • 7,024
  • 2
  • 29
  • 46
0

First of all you don't need a separate ImageView for your arrow navigation button. Just use the one from support design resources which will resize automatically according to the screen size.

Drawable upArrow = getResources().getDrawable(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        upArrow.setColorFilter(Color.parseColor("#ffffff"), PorterDuff.Mode.SRC_ATOP);
        toolbar.setNavigationIcon(upArrow);
Aman Grover
  • 1,621
  • 1
  • 21
  • 41
  • ImageView for another purpose. Home Button enabled by the code getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); I dont want change color of Arrow from code cause resource changed from API 23, and in future it can be changed even more. IMHO best aproach is styles file. – Michael Sep 13 '16 at 08:05