简体   繁体   中英

capture screen shot programmatically in android

I have gridview and show image. Every image click show the list activity as dialog based on same position. when i click back button capture screen on list activity. how can i do?

Here this sample to work but not capture list activity as dialog activity. Thanks for advanced

                View v1 =getWindow().getDecorView().getRootView();
                v1.setDrawingCacheEnabled(true);
                Bitmap bm = v1.getDrawingCache();
                BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);             
                holder.cardBack.setBackgroundDrawable(bitmapDrawable);
//              holder.cardBack.setBackgroundResource(R.drawable.a);
                holder.rootLayout.startAnimation(flipAnimation);

try this, Call this method, passing in the outer most ViewGroup that you want a screen shot of:

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;
} 

Ref : How to programmatically take a screenshot in Android?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM