Drawable drawable = getResources().getDrawable(R.mipmap.ic_back);
drawable.setTint(Color.WHITE);
1.布局中添加toolbar:
<?xml version="1.0" encoding="utf-8"?>
<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:background="?attr/colorPrimary"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:titleTextColor="?attr/colorPrimary"
app:title="Toolbar"
app:titleTextColor="#ffffff"
app:theme="@style/ToolbarTheme"//通过主题改变返回键颜色
android:minHeight="?attr/actionBarSize">
</android.support.v7.widget.Toolbar>
ToolbarTheme:
<style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<item name="colorControlNormal">#ffffff</item>
</style>
2.代码中设置显示返回键:
setSupportActionBar(mToolbar);
//设置是否有返回箭头
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//设置标题文字
mToolbar.setTitle("mToolbar");