Chrome自定义标签会在工具栏

时间:2016-10-13 14:09:55

标签: android chrome-custom-tabs

我想在ChromeCustomTabs的工具栏中添加一个操作按钮,因此我按了this tutorial

添加了按钮,但它不会显示在工具栏中,而是显示在活动的底部:

ChromeCustomTab

这是我用来创建Chrome自定义标签的代码:

private static void openUrlInChromeCustomTab(String webUrl, Activity activity, Item item) {
    if (!(webUrl.startsWith("http:") || webUrl.startsWith("https:"))) {
        webUrl = "http://" + webUrl;
    }

    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();

    Bitmap largeIcon = BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_share);

    Product product = (Product) item;

    PendingIntent pendingIntent;
    Intent intent = new Intent();
    intent.setClass(activity, SharingDummyActivity.class);

    Bundle bundle = new Bundle();
    bundle.putSerializable(SharingDummyActivity.PRODUCT_CRITERIA, product);
    intent.putExtras(bundle);

    pendingIntent =  PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);


    //builder.setActionButton(largeIcon, activity.getResources().getString(R.string.custom_tag_share_description), pendingIntent ,true);
    builder.setActionButton(largeIcon, activity.getResources().getString(R.string.custom_tag_share_description), pendingIntent);

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.launchUrl(activity, Uri.parse(webUrl));

}

如何让工具栏内的动作按钮靠近三个点? 我错过了什么吗?

1 个答案:

答案 0 :(得分:5)

问题是Chrome自定义标签只接受24/48 dp位图,我的更高。刚用另一个用接受的分辨率更改资源文件后,它工作正常。