簡體   English   中英

Chrome自定義標簽與CustomTabsIntent無法正常配合使用

[英]Chrome custom tabs not working correctly with CustomTabsIntent

我一直在嘗試探索谷歌Chrome自定義標簽工具,但有些東西讓我很感興趣。

在Android Studio上使用以下版本的庫

compile 'com.android.support:customtabs:23.2.0'

然后使用CustomTabsIntent運行示例不能正常工作。

CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
                        .setCloseButtonIcon(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ic_action_back))
                        .setToolbarColor(Color.RED)
                        .addDefaultShareMenuItem()
                        .build();
CustomTabActivityHelper.openCustomTab(getActivity(), customTabsIntent, Uri.parse(url), null);

使用它,只有setToolbarColor()正在工作。 setCloseButtonIcon()addDefaultShareMenuItem()甚至其他指令都沒有任何效果。

有沒有人經歷過這樣的事情?

有兩個不同的原因:

  • setCloseButtonIcon

    可能不起作用,因為您使用的位圖具有錯誤的尺寸。 正如developer.android.com所記錄的那樣:

    指定要用作操作按鈕的圖像源的位圖的鍵。 圖標的高度不應超過24dp(不需要填充。按鈕本身的高度為48dp),寬度/高度比小於2。

    您可以從custom-tabs-client repo獲取正確的后退箭頭位圖。

  • addDefaultShareMenuItem

    正如您在chromium.org上看到的,默認共享按鈕是一項新增功能,目前僅適用於Chrome BetaChrome Dev 您需要等待Chrome Stable使用此功能進行更新,同時此參數將在穩定版本中被忽略。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM