我正在开发游戏应用程序。但要获得背景有一些问题 基于构建图缓存的颜色,具有修复“X”和“Y”坐标。
我的代码是这样的..
mainRelativeLayout.buildDrawingCache();
Bitmap bitmap = mainRelativeLayout.getDrawingCache();
int color = bitmap.getPixel(200,320);
Log.e("color", "" + color);
但它在颜色上返回空指针异常。
答案 0 :(得分:1)
我认为这篇文章将帮助您从视图中获取位图,即使内容不在屏幕内。
Call to `getDrawingCache` returns null when scroll is enabled