DrawView
DrawView copied to clipboard
java.lang.IllegalArgumentException: width and height must be > 0
Thank you for such an awesome library! Its helping me. However, an error occured while using it and I'd like to know if you can help me. Thanks!
java.lang.IllegalArgumentException: width and height must be > 0
Crashes on line drawingView.setBackgroundImage(editingImage, BackgroundType.FILE, BackgroundScale.CENTER_INSIDE);
If removed, no error occurs.
My XML:
<com.byox.drawview.views.DrawView
android:id="@+id/drawingView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dv_draw_corners="round"
app:dv_draw_tool="pen"
app:dv_draw_enable_zoom="true"
app:dv_draw_max_zoom_factor="15"
app:dv_draw_alpha="255"
app:dv_draw_width="10"/>
configuration code:
drawingView = (DrawView) findViewById(R.id.drawingView);
drawingView.setBackgroundImage(editingImage, BackgroundType.FILE, BackgroundScale.CENTER_CROP);
drawingView.setDrawColor(getResources().getColor(R.color.colorPickerDefault))
.setZoomEnabled(true)
.setMaxZoomFactor(15)
.setDrawAlpha(255)
.setDrawWidth(maxPenSize);
drawingView.setBackgroundImage(editingImage, BackgroundType.FILE, BackgroundScale.CENTER_INSIDE);
What am I doing wrong?
Same problem here
I recently update snapshot version, please use it and tell me if the problem persists
Tried with the 1.0.2. The error is gone but the background image is not set. This is my code (Kotlin):
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_edit_picture)
val imagePath = intent.getStringExtra("imagePath")
edit_picture_view.backgroundImage(File(imagePath), BackgroundType.FILE, BackgroundScale.CENTER_INSIDE, 50)
}
Hi,
Just an fyi the same error manifests on line with code: "mZoomRegionView.drawZoomRegion(mContentBitmap, mCanvasClipBounds, 4);"
- in class Drawview.java when using an Android Device with OS 10. (Works fine on previous OS devices).
If you add a delay there is no error and it prevents the crash: new Handler().postDelayed(new Runnable() { @Override public void run() { mZoomRegionView.drawZoomRegion(mContentBitmap, mCanvasClipBounds, 4); } }, 1000);
Could you add this to the next version please?
Best wishes,
Arron
I have a solution.
drawingView.post { drawingView.setBackgroundImage(File(uri.path), BackgroundType.FILE, BackgroundScale.CENTER_INSIDE) }
thanks to byox great project, I cloned the project and fixed this bug. feel free to use it. implementation 'com.github.salario07:DrawView:1.0.4'
also see latest version from here: https://jitpack.io/#salario07/DrawView