android - 蜂窝通知 - 如何将 largeIcon 设置为正确的大小?

标签 android android-3.0-honeycomb android-notifications

我发现自己很好奇为什么 Notification.Builder 上的 setLargeIcon 方法只接受位图,而没有重载来提供资源 ID。也许是出于性能原因这样做,但 setSmallIcon 确实接受 res drawable id 似乎很奇怪。

Notification.Builder builder = new Notification.Builder(application);
// ....
builder.setLargeIcon(iconBitmap);  // Requires a Bitmap
builder.setSmallIcon(iconResId);   // Requires a drawable resource ID
Notification notification = builder.getNotification();

遗憾的是,通知中提供的位图未按比例缩放,因此需要为通知 View 提供正确大小的位图。

假设我需要提供 xhdpi、hdpi、mdpi 和 ldpi 版本的 largeIcon 位图,它们需要多大的尺寸?在文档中或在搜索更广泛的网络之后,我看不到任何提及。

最佳答案

还没有机会检查它,但 API 11 引入了以下公共(public)维度:

应该能够在将图像设置在通知上之前使用它们来缩放图像。

关于android - 蜂窝通知 - 如何将 largeIcon 设置为正确的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7220738/

相关文章:

android - 当收到多个 Android 通知时,只有最新的一个上的操作按钮有效

安卓应用更新机制

android - GCM 云连接服务器 - 如何开始使用它?

Android在第一次初始化应用程序时选择安装存储

android - 不是从 Intent 开始 Activity

Android PixelGrid OnDraw 检查/跟踪当前位置

android - 如何更新我的通知以显示我的时间计数器发生变化?

android - Android Honeycomb 中的加载程序

android - 在 Android Honeycomb 中加速 Gallery 小部件的技巧

android - 在通知栏上显示 LevelListDrawable