2

I am working on a game application. But there is some problem to get background color base on build drawing cache with fix "X" and "Y" coordinate.

My code is like this..

mainRelativeLayout.buildDrawingCache();
        Bitmap bitmap = mainRelativeLayout.getDrawingCache();
        int color = bitmap.getPixel(200,320);
        Log.e("color", "" + color);

but it return null pointer exception on color.

sloth
  • 99,095
  • 21
  • 171
  • 219
Mehul Santoki
  • 1,208
  • 1
  • 12
  • 25
  • getDrawingCache() will return null in case you didn't enable it. Try calling this method before that: setDrawingCacheEnabled(true) – Luis Ollero Jun 13 '12 at 13:00

1 Answers1

1

I think this post will help you get a bitmap from the view, even if the content is out of screen.

Call to `getDrawingCache` returns null when scroll is enabled

Community
  • 1
  • 1
Ron
  • 24,175
  • 8
  • 56
  • 97