Tutorials Android How to Use Custom Chrome Tab in Android

How to Use Custom Chrome Tab in Android

Chrome Custom Tabs gives apps more control over their web experience and make transitions between native and web content more seamless without having to resort to a WebView.

Chrome Custom Tabs allow an app to customize how Chrome looks and feels. An app can change things like:

  • Toolbar color
  • Enter and exit animations
  • Add custom actions to the Chrome toolbar, overflow menu and bottom toolbar

Chrome Custom Tabs also allow the developer to pre-start Chrome and pre-fetch content for faster loading.

To use custom chrome tab in Android, you first need to include the following dependency in your build grade file.

compile 'com.android.support:customtabs:23.4.0+'

Sync the project after adding the dependencies. Now you’re good to go.

 public static void launchChromeTab(Activity activity, String url) {
        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
        builder.setToolbarColor(ContextCompat.getColor(activity, R.color.colorPrimary));
        builder.setSecondaryToolbarColor(ContextCompat.getColor(activity, R.color.colorPrimaryDark));

        // set start and exit animations
        builder.setStartAnimations(activity, R.anim.slide_in_right, R.anim.slide_out_left);
        builder.setExitAnimations(activity, android.R.anim.slide_in_left, android.R.anim.slide_out_right);

        CustomTabsIntent customTabsIntent = builder.build();
        customTabsIntent.launchUrl(activity, Uri.parse(url));
Inline Feedbacks
View all comments
Previous Post
Android Tutorials

How to Add Rate On Google Play Button in Android

Next Post

WordPress.com vs WordPress.org: Which One to Choose?

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
Would love your thoughts, please comment.x