illegalargumentException
java.lang.IllegalArgumentException: width and height must be > 0
at com.echo.holographlibrary.BarGraph.onDraw(BarGraph.java:80)
fullImage = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888);
Comments (5)
-
repo owner -
repo owner - changed status to invalid
Not a problem with library.
-
I have exactly the same issue if BarGraph is inside HorizontallScrollView. Width and height of parent view is for sure > 0 and width and height for BarGraph is:
android:layout_width="300dp" android:layout_height="200dp"
getWidth() in onDraw() returns 0.
-
repo owner Will take a closer look soon. Sorry!
-
I will try to send you some pull request later but just for your consideration I think problem is when
MeasureSpec.UNSPECIFIED
is passed to onMeasure() of View, then no specific width/height is forced by parent and 0 is assigned. In case of unspecified width or height some default (optimal for display) sizes should be passed to setMeasuredDimensions(). Quick solution for width (which is my problem in HorizontalScrollView):
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if(widthMeasureSpec == MeasureSpec.UNSPECIFIED) { int width = mBars.size() * (int)mContext.getResources().getDisplayMetrics().density * OPT_COL_WIDTH; width += (mBars.size() - 1) * (int)mContext.getResources().getDisplayMetrics().density * OPT_PADDING_WIDTH; setMeasuredDimension(width, getMeasuredHeight()); } }
Hope it will help. Excellent lib BTW :).
- Log in to comment
You have most likely specified a negative value, or the layout for the BarGraph is 0 height or width.