Modify the menu.xml as follows:
<menu xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Icon and titles are set in code for menu_star and menu_edit -->
<item
android:id="@+id/menu_add"
android:icon="@drawable/zte_add"
android:showAsAction="always"
android:title="menu_add"
android:iconTint="@color/toolbar_back"// 此处就是修改图标颜色的地方
tools:ignore="AppCompatResource" />
Modify the code as follows:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
final MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.quickcontact, menu);
for(int i = 0; i < menu.size(); i++){
Drawable drawable = menu.getItem(i).getIcon();
if(drawable != null) {
drawable.mutate();
//这里修改为你想修改的颜色
drawable.setColorFilter(getResources().getColor(R.color.toolbar_back), PorterDuff.Mode.SRC_ATOP);
}
}
return true;