-1

ビューの背後にあるビューで描画キャッシュを取得することは可能ですか? たとえば、半透明のビューがあり、その背後にあるビューを見ることができます。では、背後のビューが表示された状態で、このビューの描画キャッシュを取得できますか?

ビューを WM に追加するコード:

 final View screenshotView = new View(this) {
                    @Override
                    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
                        super.onLayout(changed, left, top, right, bottom);

                        if (!changed) {
                            buildDrawingCache();
                            final Bitmap bitmap = Bitmap.createBitmap(getDrawingCache());
                            final File file = new File("/sdcard/test.png");
                            try {
                                file.createNewFile();
                                FileOutputStream ostream = new FileOutputStream(file);
                                bitmap.compress(Bitmap.CompressFormat.PNG, 100, ostream);
                                ostream.close();
                            } catch (Exception e) {
                                Log.e(TAG, e.toString());
                            }
                        }
                    }
                };

WindowManager.LayoutParams screenShotViewLp = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.RGBA_8888);
                screenShotViewLp.width = WindowManager.LayoutParams.MATCH_PARENT;
                screenShotViewLp.height = WindowManager.LayoutParams.MATCH_PARENT;
                screenShotViewLp.gravity = Gravity.LEFT | Gravity.TOP;

                wm.addView(screenshotView, screenShotViewLp);
4

1 に答える 1