0

I have a view which has some transparent area. Through the transparent area , I can see the view below it, now I want the view I see trough transparent area become blur. I have found some code to make a bitmap blur but how can I get the bitmap of what I'm seeing trough transparent area?

I found the buildDrawingCache function of View but do not know how to use it.

zzy
  • 1,771
  • 1
  • 13
  • 48

2 Answers2

3

Pass your view in the this method and get bitmap.

Bitmap getBitmapOfView(View v) {
    Bitmap bitmap = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);                
    Canvas c = new Canvas(bitmap);
    v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    v.draw(c);
    return bitmap;
}
Vid
  • 1,012
  • 1
  • 14
  • 29
1

You can convert your view into a bitmap. Visit this link to see how to do that.

public static Bitmap loadBitmapFromView(View v) {
   Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);                
   Canvas c = new Canvas(b);
   v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
   v.draw(c);
   return b;

}

What you're trying to achive It'll be done using fragments. Haveing on fragment over the other. So you the set blue view of lower fragment as background of upper fragment.

Community
  • 1
  • 1
Noman Rafique
  • 3,735
  • 26
  • 29