Wish B4XImageView Android Version Fix

Jack Cole

Well-Known Member
Licensed User
Longtime User
With Android v4, I get the following crash when using B4XImageView.


This is fixable with the following modification to the B4XImageView.bas inside of the XUI Views library. I don't always remember to do this after B4A is updated and I end up finding the crashes later. Could you include this in the official code?

B4X:
Private Sub UpdateClip
    If mRound Then
        mBase.SetColorAndBorder(mBackgroundColor, 0, 0, Min(mBase.Width / 2, mBase.Height / 2))
    Else
        mBase.SetColorAndBorder(mBackgroundColor, 0, 0, mCornersRadius)
    End If
#if B4J
    Dim jo As JavaObject = mBase
    Dim shape As JavaObject
    If mRound Then
        Dim radius As Double = Min(mBase.Width / 2, mBase.Height / 2)
        Dim cx As Double = mBase.Width / 2
        Dim cy As Double = mBase.Height / 2
        shape.InitializeNewInstance("javafx.scene.shape.Circle", Array(cx, cy, radius))
    Else
        Dim cx As Double = mBase.Width
        Dim cy As Double = mBase.Height
        shape.InitializeNewInstance("javafx.scene.shape.Rectangle", Array(cx, cy))
        If mCornersRadius > 0 Then
            Dim d As Double = mCornersRadius
            shape.RunMethod("setArcHeight", Array(d))
            shape.RunMethod("setArcWidth", Array(d))
        End If
    End If
    jo.RunMethod("setClip", Array(shape))
#else if B4A
    Try
        Dim jo As JavaObject = mBase
        jo.RunMethod("setClipToOutline", Array(mRound Or mCornersRadius > 0))
    Catch
        'Log(LastException)
    End Try
#end if
End Sub
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
One thing I have been doing is pulling the code out from the XUI Views library and adding it directly to my project.
 

TILogistic

Expert
Licensed User
Longtime User
?
With Android v4, I get the following crash when using B4XImageView.
note:
2. In B4A the shape is based on the set background (as in B4i). We only need to call setClipToOuline. Note that it is available in Android 5+ (minSdkVersion=21).
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…