android achartengine : trying to export graph as image throws exception

前端 未结 1 715
自闭症患者
自闭症患者 2021-01-24 20:18

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(Con         


        
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 20:34

    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.

    0 讨论(0)
提交回复
热议问题