【发布时间】:2019-08-15 13:53:53
【问题描述】:
我一直在尝试模糊图像视图并将整个布局的背景设置为模糊位图,但无济于事。基本上我想要达到的效果显示在这些图片中,它们只模糊 imageView 并将扩展的模糊图像设置为布局背景。
int color = getDominantColor(bitmap); //get dominant color of the bitmap
//create gradient
GradientDrawable gradient = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
new int[] {0xf5f5f5,color});
gradient.setCornerRadius(0f);
//setbackground of the relativelayout
rl.setBackground(gradient);//rl is relative layout
//getting dominant color of bitmap
public static int getDominantColor(Bitmap bitmap) {
Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
final int color = newBitmap.getPixel(0, 0);
newBitmap.recycle();
return color;
}
我不希望将背景设置为渐变,而是作为该图像位图的模糊结果,就像在我包含的图像中一样。
【问题讨论】:
标签: java android imageview blur blurry