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
Post a Comment