设置为“通知"时,大画面正在裁剪 [英] Big Picture is Cropping while setting to Notification

查看:106
本文介绍了设置为“通知"时,大画面正在裁剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android通知栏中显示大图片样式图片.但是我遇到了问题->当我使用以下代码在通知栏中设置图片时:

I want to show a Big Picture Style Image in my notification bar Android. But I am getting a problem -> When I set the image in notification bar using the below code:

PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(title)
            .setContentText(message)
            .setOngoing(false)
            .setAutoCancel(true)
            .setStyle(new NotificationCompat.BigPictureStyle()
            .bigPicture(bitmap))
            .setPriority(Notification.PRIORITY_HIGH)
            //.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
            .setContentIntent(resultPendingIntent);
            // mId allows you to update the notification later on.
            mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
            mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(0 , mBuilder.build());

总是从左和右角裁剪.我不想使用相同的远程视图.谁能告诉我可以放置在通知栏中的图像的尺寸和分辨率,这些图像不应被裁剪.

It is always cropped from left and right corners. I dont want to use remote views for the same. Can anyone tell me the size and the resolutions of the image that can be placed in the notification bar which should not be cropped.

谢谢

推荐答案

之所以被裁剪,是因为其比例不是2:1 您要提供大图的图像应以2:1的比例显示,否则将被裁剪或图像变小而将被拉伸.

The reason its being cropped because its not in 2:1 ratio image that you are providing for big picture should be in 2:1 ratio else it will get cropped or image is small it will get stretch.

查看此内容 https://documentation.onesignal.com/docs/android-customizations#section-big-picture

这篇关于设置为“通知"时,大画面正在裁剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆