简体   繁体   English

Chrome自定义标签:图标状态并响应用户操作

[英]Chrome Custom Tabs: Icon state and responding to user actions

It looks like the custom tab icon is static, so it couldn't respond to user changes or external changes? 看起来自定义选项卡图标是静态的,因此它无法响应用户更改或外部更改?

To take the Pinterest example, if Pinterest has a custom tab icon like "Pin It" and user clicks on it, can it be changed to "Pinned". 要获取Pinterest示例,如果Pinterest有一个自定义选项卡图标,如“Pin It”并且用户点击它,可以将其更改为“Pinned”。 If not, how should the app/tab provide user feedback after such an action? 如果没有,应用程序/选项卡应该如何在此类操作后提供用户反馈?

Icon can not be changed at the moment. 目前无法更改图标。 Not sure how to handle that though. 不知道如何处理。

This feature is now [implemented in Chrome 46] ( https://codereview.chromium.org/1291083004/ ) together with the next version of android support library that will be released soon. 此功能现在[在Chrome 46中实现]( https://codereview.chromium.org/1291083004/ )以及即将发布的下一版Android支持库。

There are two ways to update the icon of action button: 有两种方法可以更新操作按钮的图标:

  1. Using support library, you could call CustomTabSession#setActionButton(), once you have got an CustomTabSession object after creating a custom tab. 使用支持库,在创建自定义选项卡后获得CustomTabSession对象后,可以调用CustomTabSession#setActionButton()。
  2. If you prefer not to use the easy and beautiful support library, you could also achieve the same goal by binding to the CustomTabsService , call updateVisuals() and pass the IBinder object you got previously when binding. 如果您不想使用简单而美观的支持库,您也可以通过绑定到CustomTabsService来实现相同的目标,调用updateVisuals()并传递绑定时先前获得的IBinder对象。

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

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