Android Chrome自定义标签的CustomTabsIntent
示例
使用CustomTabsIntent,现在可以配置Chrome自定义标签,以便在从您的应用打开的浏览器中自定义关键的UI组件。
在某些情况下,这是使用WebView的好选择。它允许使用Intent加载网页,并具有将应用程序的某种外观注入浏览器的附加功能。
这是有关如何使用来打开网址的示例CustomTabsIntent
String url = "https://www.google.pl/"; CustomTabsIntent intent = new CustomTabsIntent.Builder() .setStartAnimations(getContext(), R.anim.slide_in_right, R.anim.slide_out_left) .setExitAnimations(getContext(), android.R.anim.slide_in_left, android.R.anim.slide_out_right) .setCloseButtonIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_arrow_back_white_24dp)) .setToolbarColor(Color.parseColor("#43A047")) .enableUrlBarHiding() .build(); intent.launchUrl(getActivity(), Uri.parse(url));
注意:
要使用自定义选项卡,您需要将此依赖项添加到build.gradle
compile 'com.android.support:customtabs:24.1.1'