我一直试图模糊图像视图,并将整个布局的背景设置为模糊位图,但无济于事。这些图片基本上显示了要实现的目标,这些图片仅模糊了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;
}
我不希望tp将背景设置为渐变,但是作为该图像位图的模糊结果,就像在我包含的图像中一样。
答案 0 :(得分:0)
有很多选择:
注意:我没有发布任何代码,因为解决方案的一部分是库或自定义类。
希望有帮助。