pio*_*543 3 notifications android android-layout android-notifications
我一直在使用雪崩消息通知处理应用程序,并且我遇到了比Lollipop Android版驱动设备更早的通知大图标大小的问题.
在Lollipop和Marshmallow设备上它看起来很好:

但是当我在Android 4.4模拟器上打开一个应用程序时,我发现了这个:

图像没有缩放,适合,只是在中间裁剪.它看起来不太好.
注意:要明确说明,此大型通知图标将与消息日期和内容一起从服务器下载.它看起来像这样:
在我的雪崩通知课程中经过几个小时的工作后,我添加了两种方法,只有在检测到Android pre-lollipop版本时才会运行:
更改后,我在同一Kitkat模拟器(Moto X 2013)上的通知图标看起来好多了:

你能否告诉我是否有更简单的方法来解决这个问题?如果没有,除了96x96之外,我需要支持哪些图标尺寸?
提前致谢
小智 6
如果我理解正确,你想让棒棒糖设备和棒棒糖前的通知图标看起来都很好,根据我的经验,我所做的是确保两个SDK的外观都是这样的:
对于通知大图标我使用这些大小的资源:96x96(hdpi)64x64(mdpi)128x128(xhdpi)192x192(xxhdpi)256x256(xxxhdpi)
我使用此代码配置通知样式:
NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
notiStyle.setBigContentTitle(title);
notiStyle.bigText(msg);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(msg)
.setColor(coloresOnboarding.getColor())
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.setSmallIcon(R.mipmap.ic_launchersmall)
.setAutoCancel(true)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcherlarge))
.setStyle(notiStyle);
Intent resultIntent = new Intent(context, HeadAppMain.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
int mId=1;
mBuilder.setAutoCancel(true);
Run Code Online (Sandbox Code Playgroud)我希望这能帮助你.
| 归档时间: |
|
| 查看次数: |
2330 次 |
| 最近记录: |