Android Chrome CustomTabsIntent customize toolbar design

84 views Asked by At

As I'm facing some issue with WebView, I am attempting to utilize Chrome Custom Tabs (CustomTabsIntent). However, I encounter difficulties in customizing its toolbar. Specifically, I aim to remove the share and menu icons from the CustomTabsIntent toolbar. Is there any way to achieve this? Below is my code.

implementation 'androidx.browser:browser:1.7.0'

CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
            .setShowTitle(true)
            .setToolbarColor(ContextCompat.getColor(this, R.color.orange_color))
            .build();

customTabsIntent.launchUrl(this, Uri.parse("https://developer.android.com"));

I want to remove menu and share icons in below toolbar.

enter image description here

1

There are 1 answers

0
Gedanggoreng On

To remove Share icon in Chrome Custom Tabs, just add .setShareState(CustomTabsIntent.SHARE_STATE_OFF).

So, your code will be like this.

CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
            .setShowTitle(true)
            .setToolbarColor(ContextCompat.getColor(this, R.color.orange_color))
            .setShareState(CustomTabsIntent.SHARE_STATE_OFF)
            .build();

While for removing the Menu icon, it seems that it's not possible at the time of this writing. it's achievable only if you own/manage the destination url.

You can remove the Menu icon using App Links Assistant. More info about the App Links Assistant here.