gpt4 book ai didi

android - 没有卡片背景无法将页面添加到 Android Wear 通知

转载 作者:行者123 更新时间:2023-11-29 15:59:32 25 4
gpt4 key购买 nike

Android Wear 很可能不支持此功能,但似乎应该有一些解决方法。我想向通知添加自定义第二页,但我不希望它具有白色卡片背景。

以下是我创建通知的方式:

Intent secondPageIntent = new Intent(this, SecondPageActivity.class);
PendingIntent secondPagePendingIntent = PendingIntent.getActivity(this, 0, secondPageIntent, 0);


Notification secondPageNotification = new NotificationCompat.Builder(this)
.extend(new NotificationCompat.WearableExtender()
.setDisplayIntent(secondPagePendingIntent)
.setHintShowBackgroundOnly(true)
)
.build();

Intent firstPageIntent = new Intent(this, FirstPageActivity.class);
PendingIntent firstPagePendingIntent = PendingIntent.getActivity(this, 0, firstPageIntent, PendingIntent.FLAG_UPDATE_CURRENT);


NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.extend(new NotificationCompat.WearableExtender()
.setDisplayIntent(firstPagePendingIntent)
.setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.background))
.addPage(secondPageNotification)
);


NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(curNotificationId++, builder.build());

我试过:

  1. 设置不执行任何操作的 setHintShowBackgroundOnly
  2. 从 SecondPageActivity 中,尝试获取 parentActivity 并将其 alpha 设置为 0。不起作用,parentActivity 为空。
  3. 调用 setCustomContentHeight(0) 不会移除卡片,它只会变瘦
  4. 我尝试不使用第二个页面,而是在用户滑动时启动一个 Activity ,但它看起来不太好

我真的不知道接下来要尝试什么。我是一位经验丰富的工程师,但对 Android 还很陌生。任何想法或建议都会有所帮助。

谢谢!

最佳答案

如果你想去掉你必须设置的白卡

setCustomSizePreset(WearableExtender.SIZE_FULL_SCREEN)


所以不是这样的:
custom content with card decoration

您的自定义内容将出现在整个屏幕上(没有卡片装饰)。 custom content without card decoration

请注意,自定义 Activity 的背景由 list 中声明的​​样式定义。不幸的是,任何具有透明背景的主题都不起作用,因此背景需要不透明:(

此处作为问题提交:https://code.google.com/p/android/issues/detail?id=73900
我真的希望他们将来允许透明背景:\

关于android - 没有卡片背景无法将页面添加到 Android Wear 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25374269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com