我使用这段代码打开Chrome自定义选项卡中的链接。但是setToolbarColor()
和setSecondaryToolbarColor()
都被标记为@Deprecated
。我没有找到任何替代方法。
注意:Android Studio建议使用setDefaultColorSchemeParams
,但没有找到任何示例。
Uri uri = Uri.parse(url);
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
intentBuilder.setToolbarColor(ContextCompat.getColor(activity,R.color.background));
intentBuilder.setSecondaryToolbarColor(ContextCompat.getColor(activity,R.color.background));
intentBuilder.setStartAnimations(activity,R.anim.slide_in_right,R.anim.slide_out_left);
intentBuilder.setExitAnimations(activity,android.R.anim.slide_in_left,android.R.anim.slide_out_right);
CustomTabsIntent customTabsIntent = intentBuilder.build();
customTabsIntent.launchUrl(activity,uri);
params
中添加.setToolbarColor(ContextCompat.getColor(activity, R.color.background))
,并设置intentBuilder.setColorScheme(CustomTabsIntent.COLOR_SCHEME_DARK)
。 - CoolMindintentBuilder.setColorScheme(CustomTabsIntent.COLOR_SCHEME_DARK)
或默认的颜色方案来检查答案?在我的情况下,它会绘制白色的工具栏。 - CoolMindCustomTabsIntent.COLOR_SCHEME_DARK
对我来说不起作用,还导致了崩溃。 - user14817809.setDefaultColorSchemeParams(params)
吗? - CoolMind