[英]How can I resize an image in android to use it in an expanded notification?
That's how I define a style for the notification: 这就是我定义通知样式的方式:
NotificationCompat.BigPictureStyle notiStyle = new
NotificationCompat.BigPictureStyle();
notiStyle.setBigContentTitle(context.getString(R.string.notification_ticker));
notiStyle.setSummaryText(title);
notiStyle.bigPicture(map);
notiStyle.bigLargeIcon(map); //map - bitmap
But the bitmap is too large, and notification shows only a piece of an image with full width and cropped by height, a large icon shows a little part in the center of the image. 但是位图太大,通知仅显示全幅图像并按高度裁切的图像,大图标显示图像中心的一小部分。
use this code , it helps you : 使用此代码,它可以帮助您:
Bitmap yourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);
You can resize your Bitmap before setting it to the View with the following code. 您可以使用以下代码在将位图设置为“视图”之前调整其大小。
Bitmap b = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)
profileImage.setImageBitmap(Bitmap.createScaledBitmap(b, 120, 120, false));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.