2

I can't find how change color of icons on my action bar (search and sort icon on the right). I want that all icons will white like home icon on the right. I can change android:fillColor color in drawable/ic_search.xml, but i want use something like android:tint.

Here is my xml:

layout.xml

    <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:contentInsetStartWithNavigation="0dp">

        <ImageView
            android:id="@+id/toolbar_logo"
            android:layout_width="32dp"
            android:layout_height="match_parent"
            android:scaleType="fitCenter"
            android:layout_marginRight="16dp"
            app:srcCompat="@drawable/ic_small_logo" />

        <Spinner
            android:id="@+id/toolbar_categories_spinner"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            />

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

</android.support.design.widget.AppBarLayout>

toolbar_menu.xml

 <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:yourapp="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/tools">

   <item
        android:id="@+id/action_search"
        android:icon="@drawable/ic_search"
        android:title="@android:string/search_go"

        yourapp:actionViewClass="android.support.v7.widget.SearchView"
        yourapp:showAsAction="always|collapseActionView" />
    <item
        android:id="@+id/action_sort"
        android:icon="@drawable/ic_sort"
        android:title="@string/action_sort"
        yourapp:showAsAction="always" />
</menu>

style.xml

 <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="colorPrimary">#FF3D3D3D</item>
    <item name="android:textColorPrimary">#FFFFFFFF</item>
    <item name="android:textColorSecondary">#FFA7A7A7</item>
</style>

Here is screenshot how it looks now:

enter image description here

Matthew Shearer
  • 2,715
  • 3
  • 23
  • 32
Anton111111
  • 656
  • 1
  • 7
  • 23

3 Answers3

2

You can't set their color. Just download and use white icons.

Roman Samoilenko
  • 932
  • 12
  • 25
0

You have to set white icon or set color pragmatically

refer

Change color android.support.v7.widget.SearchView

Community
  • 1
  • 1
Learning Always
  • 1,563
  • 4
  • 29
  • 49
0

this might help you,

private void setColor(ImageView imageView) {
    int color = Color.parseColor("#EE3A8C");
    imageView.setColorFilter(color);
}

image = (ImageView) findViewById(R.id.image);
setColor(image);
musica
  • 1,373
  • 3
  • 15
  • 34