How to change the color of black arrow(Back button) in searchview I have tried by customizing with below code
ImageView backid = (ImageView) searchViewAndroidActionBar.findViewById(R.id.search_button);
backid.setColorFilter(ContextCompat.getColor(Shopping_CategoriesCommon.this, R.color.white), PorterDuff.Mode.SRC_IN);
backid.setImageResource(R.drawable.search);
but it doesn't work
Add this attribute to your toolbar in xml file app:collapseIcon
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbarHeight"
app:collapseIcon="@drawable/collapseBackIcon" />
After a day search i resolved it by adding app:collapseIcon="@drawable/back_arrow"
to the custom toolbar
<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/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="vertical"
app:collapseIcon="@drawable/back_arrow"/>
I could change the color using Reflection.
try {
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Field mCollapseIcon = toolbar.getClass().getDeclaredField("mCollapseIcon");
mCollapseIcon.setAccessible(true);
Drawable drw = (Drawable) mCollapseIcon.get(toolbar);
drw.setTint(color);
}
catch (Exception e) {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With