Skip to content

Instantly share code, notes, and snippets.

@balachandarlinks
Forked from androidcodehunter/toolbarcolor
Created November 3, 2021 14:57
Show Gist options
  • Save balachandarlinks/0e4d55e6d215d5bbb8b0a7c263c22301 to your computer and use it in GitHub Desktop.
Save balachandarlinks/0e4d55e6d215d5bbb8b0a7c263c22301 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