我正在开发一个支持深色主题的Android应用程序。我使用自定义 Chrome 选项卡来显示网页。只是想知道是否有任何方法可以在自定义 chrome 选项卡中强制使用深色主题。
使用下面的代码。
@ColorInt int colorPrimaryLight = ContextCompat.getColor(YourActivity.this, R.color.dark_color);
@ColorInt int colorPrimaryDark = ContextCompat.getColor(YourActivity.this, R.color.dark_color);
CustomTabsIntent intent = new CustomTabsIntent.Builder()
.setDefaultColorSchemeParams(new CustomTabColorSchemeParams.Builder()
.setToolbarColor(colorPrimaryLight)
.build())
.setColorSchemeParams(CustomTabsIntent.COLOR_SCHEME_DARK,
new CustomTabColorSchemeParams.Builder()
.setToolbarColor(colorPrimaryDark)
.build())
.build();
您可以在这里找到来源。