问题描述
我用这个简单的code在安卓4.1或更高版本设置的通知。它运作良好,但我的问题带有SmallIcon和LargeIcon。据我所知,SmallIcon显示在状态栏和LargeIcon显示在下拉列表中。
NotificationCompat.Builder建设者=新NotificationCompat.Builder(本);
builder.setTicker(以下简称股票);
builder.setContentTitle(标题);
builder.setContentText(以下简称文);
builder.setSmallIcon(R.drawable.my_small_icon);
位图BM = BitmapFactory.de codeResource(getResources(),R.drawable.my_96px_large_icon);
builder.setLargeIcon(BM);
NotificationManager纳米=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
nm.notify(direct_tag,NOTIF_ALERTA_ID,builder.build());
我的问题是接下来的:
-
在通知启动,裁剪过大的小图标显示下的北京时间的文字来,而不是显示无尺寸过大它原来的SmallIcon。
-
在下拉列表中我看到左边的LargeIcon,这是很好的。但我也看到右侧的小图标,旁边的通知的时间。我不想证明。
任何帮助吗?先谢谢了。
-
在我的应用程序提供了较大的(128×128像素)的PNG绘制小图标,它显示了规模化,无需裁剪。是位图文件或者作为XML资源的绘制界定?在XML中,你可以指定显示(如裁剪)的几个方面。仔细检查您的XML或只使用PNG / JPG。
-
作为Android在Notification.setSmallIcon API文档()明确规定:
AFAIK有没有办法,你可以重写的行为,除非你提供自己的通知模板(通过Notification.setContent()
I use this simple code to set a Notification in Android 4.1 or higher.It works well, but my problem comes with SmallIcon and LargeIcon.I understand that SmallIcon is shown in the status bar and the LargeIcon is shown in the dropdown list.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setTicker("The ticker");
builder.setContentTitle("The title");
builder.setContentText("The text");
builder.setSmallIcon(R.drawable.my_small_icon);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.my_96px_large_icon);
builder.setLargeIcon(bm);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify("direct_tag", NOTIF_ALERTA_ID, builder.build());
My problem are the next:
When the notification is launched, a cropped oversized Small Icon is show next to "The Ticker" text, instead of showing the original SmallIcon without oversizing it.
In the dropdown list I see the LargeIcon on the left, that's good. But I also see the small icon on the right, next to the time of the notification. I don't want to show that.
Any help?Thanks in advance.
In my application I provide large (128x128 px) PNG drawable as small icon, and it shows scaled and without cropping. Is your drawable defined in bitmap file or maybe as XML resource? In XML you can specify several aspects of display (e.g. cropping). Double check your XML or use just PNG/JPG.
As Android API documentation on Notification.setSmallIcon() clearly states:
AFAIK there's no way you can override the behaviour, unless you provide your own notification template (via Notification.setContent()
这篇关于NotificationCompat 4.1 SetSmallIcon和SetLargeIcon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!