Chrome 自定义选项卡在工具栏外显示操作按钮
Chrome custom tab shows action button outside the toolbar
我想向 ChromeCustomTabs 的工具栏添加一个操作按钮,所以我遵循了 this tutorial
该按钮已添加,但未出现在工具栏中,而是出现在 activity 的底部:
这是我用来创建 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));
}
如何让工具栏内的操作按钮靠近三个点?
我错过了什么吗?
问题是 Chrome 自定义选项卡只接受 24/48 dp 位图,我的更高。在用可接受的分辨率将资源文件更改为另一个之后,它工作正常。
我想向 ChromeCustomTabs 的工具栏添加一个操作按钮,所以我遵循了 this tutorial
该按钮已添加,但未出现在工具栏中,而是出现在 activity 的底部:
这是我用来创建 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));
}
如何让工具栏内的操作按钮靠近三个点? 我错过了什么吗?
问题是 Chrome 自定义选项卡只接受 24/48 dp 位图,我的更高。在用可接受的分辨率将资源文件更改为另一个之后,它工作正常。