简体   繁体   English

Chrome 自定义标签、隐藏关闭按钮和处理设备后退按钮

[英]Chrome Custom Tabs, Hide Close Button and handle Device back button

I am using chrome custom tabs in Xamarin android application and opening a google page url (it would be my website url in future), I want to know if it possible to hide the close button?我在 Xamarin android 应用程序中使用 chrome 自定义选项卡并打开一个谷歌页面 url(将来会是我的网站 url),我想知道是否可以隐藏关闭按钮? currently if user closes the custom tab, a blank page is shown, I don't want user to close the tab.当前,如果用户关闭自定义选项卡,则会显示一个空白页面,我不希望用户关闭该选项卡。

在此处输入图片说明

Secondly if user presses the device back button, same thing happens, a blank page is shown.其次,如果用户按下设备后退按钮,也会发生同样的事情,显示一个空白页面。

What are the possible things I can do?我可以做哪些可能的事情?

In terms of the close button, no, you can not remove it.就关闭按钮而言,不,您无法将其删除。 You can change it from an X to a back arrow, but that is it.您可以将其从X更改为后退箭头,但仅此而已。

Chrome Custom Tabs is not designed to be used as an embedded browser, but as a way to open content that is external to yours, an Auth2 process, to show a link that is not within your domain, etc.. and thus keep the user within your app experience, once they are done with that external content, they return to your app via the close button or the soft/hard back button. Chrome 自定义选项卡并非旨在用作嵌入式浏览器,而是用作打开您的外部内容、Auth2 进程、显示不在您的域内的链接等的一种方式,从而保留用户在您的应用体验中,一旦他们处理完外部内容,他们就会通过关闭按钮或软/硬后退按钮返回到您的应用。

If you are looking for an embedded browser, Google/Chrome's dev team still recommend using a WebView .如果您正在寻找嵌入式浏览器,Google/Chrome 的开发团队仍然建议使用WebView

If you want the user to feel like Custom Tabs is a modal dialog, use the default “X” button.如果您希望用户觉得自定义选项卡是一个模态对话框,请使用默认的“X”按钮。 If you want the user to feel the Custom Tab is part of the application flow, use the back arrow.如果您希望用户觉得自定义选项卡是应用程序流程的一部分,请使用后退箭头。

re: https://developer.chrome.com/multidevice/android/customtabs回复: https : //developer.chrome.com/multidevice/android/customtabs

Instead of using custom tabs you can use WebView to load your web pages.您可以使用 WebView 加载您的网页,而不是使用自定义选项卡。 While you can't remove the 'X' arrow, you can create an activity with a WebView as its XML element and use the WebView to load your web pages.虽然您无法移除“X”箭头,但您可以创建一个以 WebView 作为其 XML 元素的活动,并使用 WebView 加载您的网页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM