Skip to content

Instantly share code, notes, and snippets.

@hossinasaadi
Forked from androidcodehunter/toolbarcolor
Created January 31, 2018 11:21
Show Gist options
  • Save hossinasaadi/6acc15d34fd06e58121899944ccb2d17 to your computer and use it in GitHub Desktop.
Save hossinasaadi/6acc15d34fd06e58121899944ccb2d17 to your computer and use it in GitHub Desktop.
How to change toolbar back arrow color and title color?
From theme
<style name="SearchToolbar" parent="Theme.AppCompat.Light.NoActionBar">
//toolbar back arrow color
<item name="android:textColorSecondary">@android:color/white</item>
//toolbar title color
<item name="android:textColorPrimary">@android:color/white</item>
</style>
Also we can do it from java code:
private void setupToolbar() {
//for crate home button
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(mToolbar);
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final Drawable upArrow = ContextCompat.getDrawable(getActivity(), R.drawable.abc_ic_ab_back_material);
upArrow.setColorFilter(ContextCompat.getColor(getActivity(), R.color.white), PorterDuff.Mode.SRC_ATOP);
activity.getSupportActionBar().setHomeAsUpIndicator(upArrow);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment