6

我想向 ChromeCustomTabs 的工具栏添加一个操作按钮,所以我按照本教程进行操作

该按钮已添加,但它没有出现在工具栏中,而是出现在活动的底部:

Chrome 自定义选项卡

这是我用来创建 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));

}

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

4

1 回答 1

6

问题是 Chrome 自定义选项卡只接受 24/48 dp 位图,我的更高。就在使用接受的分辨率将资源文件更改为另一个之后,它工作正常。

于 2016-10-14T09:05:55.480 回答