我在android中实现了新的Chrome Custom Tab,我使用以下代码打开
Uri uri = Uri.parse("https://akash.plobal.com/ploicy");
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
intentBuilder.setToolbarColor(Color.BLACK);
intentBuilder.setShowTitle(true);
intentBuilder.build().launchUrl(getActivity(), uri);
Run Code Online (Sandbox Code Playgroud)
我需要隐藏工具栏中标题下方的URL
在我的应用程序中,我目前使用Web视图显示一些内容,然后使用Javascript注入快速填写用户的表单.唯一的问题是,与Chrome自定义标签相比,Webview的速度非常慢.是否可以将Javascript代码注入这些自定义选项卡?
例如,以下是我目前使用的一些代码:
myWebView.loadUrl("javascript:document.getElementById('join_first_name').value='" + name + "';void(0); ");
Run Code Online (Sandbox Code Playgroud) 有没有办法在Chrome自定义标签中更改标题颜色?
我应用了Chrome自定义标签来显示网页.为此,我使用了CustomTabsIntent.Builder类.但是,没有可以更改标题颜色的界面.
String url = "www.google.com";
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
intentBuilder.setToolbarColor(getResources().getColor(R.color.primary));
intentBuilder.setShowTitle(true);
intentBuilder.setCloseButtonIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_arrow_back));
intentBuilder.setStartAnimations(getActivity(), R.anim.slide_in_right, R.anim.slide_out_left);
intentBuilder.setExitAnimations(getActivity(), android.R.anim.slide_in_left, android.R.anim.slide_out_right);
CustomTabActivityHelper.openCustomTab(getActivity(), intentBuilder.build(), Uri.parse(url), new WebviewFallback());
Run Code Online (Sandbox Code Playgroud)
根据上述代码,Chrome自定义标签会显示黑色标题文字.我想将标题更改为白色.
我有一个应用程序Chrome custom tabs
用来打开一些链接,我需要在用户留在Chrome上的每一秒都有事件,或者知道他在Chrome上停留了多少时间.对我来说,唯一的方法是使用a Service
.有可能以不同的方式做到这一点吗?
在Chrome custom tabs
似乎并不受deeplinking启动其他应用程序.
例如,Chrome
使用此URL启动时的PayPal付款.它将询问用户是否必须使用PayPal应用程序或Chrome打开URL.
但事实并非如此Chrome custom tabs
.
如果我使用自定义方案(myapp://deeplinkurl/
)它可以正常工作.
如何允许应用程序覆盖http方案?
public void openHomePage() {
final CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(ContextCompat.getColor(getActivity(), R.color.primary));
final Bitmap backButton = BitmapFactory.decodeResource(getResources(), R.drawable.ic_arrow_back_black_48dp);
builder.setCloseButtonIcon(backButton);
builder.setShowTitle(true);
final CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getActivity(), Uri.parse(mTvHomepage.getText().toString()));
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试更改自定义Chrome标签的操作栏上的默认关闭按钮.我试图设置使用setCloseButtonIcon()
但是,默认关闭按钮仍然显示.我想改变接近箭头的方法.
我的代码如下:
public void openHomePage() {
final CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(ContextCompat.getColor(getActivity(), R.color.primary));
final Bitmap backButton = BitmapFactory.decodeResource(getResources(), R.drawable.ic_arrow_back_black_48dp);
builder.setCloseButtonIcon(backButton);
builder.setShowTitle(true);
final CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getActivity(), Uri.parse(mTvHomepage.getText().toString()));
}
Run Code Online (Sandbox Code Playgroud)
提前谢谢了,
在我的应用程序中,我在CustomTabsIntent或WebView中显示外部HTML站点:
if (customTabsIntent != null) customTabsIntent.launchUrl(this, Uri.parse("http://some.where.com/site.html"));
else startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://some.where.com/site.html")));
Run Code Online (Sandbox Code Playgroud)
但该HTML的风格已经更新,但我的智能手机显示旧样式(旧字体等).
在*.html文件中有一个*.css引用:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href='https://my.site.com/assets/css/style.css' rel='stylesheet' type='text/css'>
</head>
Run Code Online (Sandbox Code Playgroud)
在那个*.css文件中,引用了一个单独的字体; 例如:
@font-face {
font-family: 'MyFontRegular';
src: url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.woff') format('woff'),
url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.eot') format('embedded-opentype');
}
Run Code Online (Sandbox Code Playgroud)
正如我所说,智能手机中的Chrome浏览器不显示引用的字体,因为它会关闭http://或https://.当我手动将该方案添加到地址栏中时,将显示正确的样式.
当我的Android应用程序调用它时,如何在我的android浏览器的地址字段中强制https://方案?
android webview android-webview chrome-custom-tabs android-customtabs
我尝试更改Chrome自定义标签中的关闭按钮的默认图标(CustomTabsIntent.Builder)
简单的测试代码:
Bitmap closeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
intentBuilder.setCloseButtonIcon(closeIcon);
Run Code Online (Sandbox Code Playgroud)
但没有任何反应.为什么?(Nexus 7,Marshmallow)
在某些情况下,用户可能不希望Chrome自定义标签显示在其浏览历史记录中.该应用是否有任何方式可以告知Chrome自定义标签以隐身模式显示网页,并避免将该网址存储在用户正常浏览历史记录中?
如果目前无法实现,那么有人可以在哪里提交功能请求?
谢谢!
使用标准的Android WebViews WebView.loadUrl(String url, Map<String, String> additionalHttpHeaders)
.如何使用Chrome自定义标签添加其他标头?