android - How I use the image of a screenshot? -


i want use code of link: how take screenshot , share programmatically take screenshots of application. want picture produced use change background, layout.setbackgroundresource(resid). how can this? find image's path use change background?

first need view want screen shot of:

view anyview = findviewbyid(r.id.anyview); 

then use method take screenshot:

public bitmap screenshot(view view) {     bitmap bitmap = bitmap.createbitmap(view.getwidth(),             view.getheight(), config.argb_8888);     canvas canvas = new canvas(bitmap);     view.draw(canvas);     return bitmap; } 

like this:

bitmap screenshot = screenshot(anyview); 

bitmaps can't set background image lets convert drawable:

drawable drawablescreenshot = new bitmapdrawable(getresources(), screenshot); 

now set view background:

anyview.setbackgrounddrawable(drawablescreenshot); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -