Android - „setToolbarColor (int)” i „setSecondaryToolbarColor (int)” są przestarzałe
Dec 13 2020
Używam tego kodu do otwierania linków z niestandardowymi kartami Chrome. Ale to pokazano @Deprecated
na setToolbarColor()
i setSecondaryToolbarColor()
. Nie znalazłem nic do wymiany.
Uwaga: Android Studio sugeruje „Zamiast tego użyj setDefaultColorSchemeParams”. ale nie znalazłem na to żadnych przykładów.
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);
Odpowiedzi
5 MLFR2kx Dec 13 2020 at 20:13
CustomTabColorSchemeParams
Zamiast tego użyj : Odniesienie
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);