我使用这段代码打开Chrome自定义标签的链接。但它显示的是@Deprecated为setToolbarColor()和setSecondaryToolbarColor()。我还没找到可以替换的东西。
注意: Android建议“使用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);发布于 2020-12-13 13:13:32
使用CustomTabColorSchemeParams代替:
Uri uri = Uri.parse(url);
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
CustomTabColorSchemeParams params = new CustomTabColorSchemeParams.Builder()
.setNavigationBarColor(ContextCompat.getColor(activity,R.color.background))
.setToolbarColor(ContextCompat.getColor(activity,R.color.background))
.setSecondaryToolbarColor(ContextCompat.getColor(activity,R.color.background))
.build();
intentBuilder.setColorSchemeParams(CustomTabsIntent.COLOR_SCHEME_DARK, params);
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);https://stackoverflow.com/questions/65275742
复制相似问题