-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