Skip to content Skip to sidebar Skip to footer

Android Achartengine : Trying To Export Graph As Image Throws Exception

in an android app, am attempting to export the graph (which I drew using achartengine) as Bitmap object via this code public static Bitmap loadBitmapFromView(Context context, View

Solution 1:

Per http://developer.android.com/reference/android/view/View.html#getLayoutParams() that method returns the

... layout parameters. These supply parameters to the parent of this view specifying how it should be arranged.

i.e. these are inputs to the layout computation:

LayoutParams ... describes how big the view wants to be for both width and height. For each dimension, it can specify one of an exact number, MATCH_PARENT, WRAP_CONTENT

You need the actual View size, that is, the result of the layout computation.

If this View is already laid out on screen, then view.getWidth() and view.getHeight() should return its actual size. In that case, calling view.layout(...) may put the displayed View in a weird state that you should restore, and again you want to pass actual size info, not layout params.

If this View is not on screen, then view.measure(widthMeasureSpec, heightMeasureSpec) is supposed to be called before view.layout(...). Do read the View docs.

Post a Comment for "Android Achartengine : Trying To Export Graph As Image Throws Exception"