Jon
Jon

Reputation: 121

Android Create View of Display

I am trying to create a View of the current display so I can call the following methods to create a Bitmap:

 v1.setDrawingCacheEnabled(true);
 current = Bitmap.createBitmap(v1.getDrawingCache(), 1686, 136, (631-168), (343-136));
 v1.setDrawingCacheEnabled(false);

To create the View I tried this line

View v1 = mCurrentUrlMask.getRootView();

I got the error "Symbol 'mCurrentUrlMask' cannot be resolved."

I'm looking to create a bitmap of a section of the screen, and thoughts you have on this issue are greatly appreciated.

Upvotes: 2

Views: 192

Answers (1)

Elltz
Elltz

Reputation: 10859

1

View v1 = MainActivity.this.getWindow().getDecorView();//editted
v1.buildDrawingCache();
//your rest of the code. 
// you will get a bitmap of the whole screen.

or you could use ViewSnapper

Upvotes: 1

Related Questions