-1
是否有可能得到的观点背后的意见绘图缓存?例如,我有一个半透明的视图,我可以看到它背后的意见。那么,我可以在后面的视图中看到这个视图的图形缓存吗?View.getDrawingCache()与背景半透明,
代码在那里我加入了以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);
我的看法是从服务直接添加到窗口管理器没有活动 – arts777
这个复杂的事情有点:)你可以发布用于连接视图到'WindowManager'的代码? –
我已经添加了代码的问题 – arts777