[英]Blur Image bitmap and set it as background
我一直在嘗試模糊圖像視圖並將整個布局的背景設置為模糊的位圖無濟於事。 基本上我試圖實現的內容顯示在這些圖片中,它們只模糊 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 將背景設置為漸變,而是作為該圖像位圖的模糊結果,就像我包含的圖像一樣。
有很多選擇:
注意:我沒有發布任何代碼,因為解決方案的一部分是庫或自定義類。
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.