How to change a title color in Chrome Custom Tabs

Daehee Han picture Daehee Han · Sep 12, 2015 · Viewed 7.7k times · Source

Is there any way to change a title color in Chrome Custom Tabs?

I applied Chrome custom tabs to show a web page. To do, I utilized CustomTabsIntent.Builder class. However, there is no interface to change a title color.

String url = "www.google.com";
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
intentBuilder.setToolbarColor(getResources().getColor(R.color.primary));
intentBuilder.setShowTitle(true);
intentBuilder.setCloseButtonIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_arrow_back));
intentBuilder.setStartAnimations(getActivity(), R.anim.slide_in_right, R.anim.slide_out_left);
intentBuilder.setExitAnimations(getActivity(), android.R.anim.slide_in_left, android.R.anim.slide_out_right);
CustomTabActivityHelper.openCustomTab(getActivity(), intentBuilder.build(), Uri.parse(url), new WebviewFallback());

Based on the above code, Chrome Custom Tabs displays a black-colored title text. I want to change the title to a white color.

Answer

Stanislav Zakharov picture Stanislav Zakharov · Oct 8, 2016

You can't change color of tittle programmatically in Chrome Custom Tab. The only way you can follow is Material Design Specifications.

If you have primary and primaryDark color of your app with dark shade, than Custom Tabs will use dark tittle, dark close button and dark overflow menu button.

Example of dark shade colors in Material Palette

If you have primary and primaryDark color with light shade, than Chrome Custom Tabs will use light tittle etc.

Example of light shade colors in Material Palette

So, you must pay attention on number of you primary and primaryDark color.