Android 2.1 View's getDrawingCache() method always returns null

Posted by Impression on Stack Overflow See other posts from Stack Overflow or by Impression
Published on 2010-05-12T08:41:06Z Indexed on 2010/05/12 8:44 UTC
Read the original article Hit count: 733

Filed under:
|
|
|
|

Hello,

I'm working with Android 2.1 and have the following problem: Using the method View.getDrawingCache() always returns null.

Example code:

public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState);

setContentView(R.layout.main);

final View view = findViewById(R.id.ImageView01); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); final Bitmap bmp = view.getDrawingCache(); System.out.println(bmp); }

I've already tried different ways to configure the View object for generating the drawing cache (e.g. View.setWillNotDraw(boolean) and View.setWillNotCacheDrawing(boolean)), but nothing works.

What is the right ways, or what do I wrong?

© Stack Overflow or respective owner

Related posts about android

Related posts about drawing