The error has nothing to do with pnl.SetLayoutAnimated.
Hi Erel,
the compiler show the error within this line: "imgCard.SetBitmap(aImg.Resize(pnl.Width, 250dip, true))" (note that imgCard is defined within "CardFull_itemlayout" layout file).
Private Sub CreateItem (cfv As CardFullValue) As B4XView
'code before...
Private aImg As Bitmap = cfv.Img
If aImg.IsInitialized Then
imgCard.SetBitmap(aImg.Resize(pnl.Width, 250dip, true))
End Sub
I think I agree with you (that this error shouldn't be related to running ".SetLayoutAnimated ()" but the strange thing is that if I comment "pnl.SetLayoutAnimated (0,0,0,100% x, 100% y)" or
I change from this: "pnl.SetLayoutAnimated (0,0,0,100%x, 100%y)" to this: "pnl.SetLayoutAnimated (0,0,0,Root.width, Root.height)" the above error is displayed.
If I enable "pnl.SetLayoutAnimated (0,0,0,100% x, 100% y)" just before "pnl.LoadLayout("CardFull_itemlayout")" the error disappears and the (B4i) app works correctly.
I did the above test also within the B4A version of the app (same identical code) and if I comment .SetLayoutAnimated () I got a crash and an error on the same B4X statement / line: "imgCard.SetBitmap(aImg.Resize(pnl.Width, 250dip, KeepAspectRatio))".
If I enable the "SetLayoutAnimated ()" the error disappear and the B4A App works correctly.
Private pnl As B4XView = xui.CreatePanel("")
pnl.SetLayoutAnimated (0,0,0,100%x, 100%y)
pnl.LoadLayout("CardFull_itemlayout")
The error within B4A version is:
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:1113)
at android.graphics.Bitmap.createBitmap(Bitmap.java:952)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:807)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Resize(CanvasWrapper.java:568)
at cutethings.android.botegapp.businesscard._createitem(businesscard.java:394)
at cutethings.android.botegapp.businesscard._loadcard(businesscard.java:815)
at cutethings.android.botegapp.businesscardlist$ResumableSub_clvCardList_ItemClick.resume(businesscardlist.java:223)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1764)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8043)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
But this is not my primary issue (I keep the "SetLayoutAnimated ()" and all work fine).
My main issue to solve is in #9 of this post (and I have this problem only within B4i versione of the app).
SOLVED:
Sub B4XPage_Resize (Width As Int, Height As Int)
LoadCard (AppGlobals.CardFullContent)
End Sub
I solved the panel resize problem calling the sub that buld and pupulate it with the B4XPage_Resize.